mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
replace operations on Dish with apply
This commit is contained in:
parent
48f3a3b18f
commit
fa87fc8325
2 changed files with 25 additions and 10 deletions
|
@ -9,7 +9,6 @@ import Utils from "../core/Utils";
|
|||
import Dish from "../core/Dish";
|
||||
import BigNumber from "bignumber.js";
|
||||
import log from "loglevel";
|
||||
import * as ops from "./index";
|
||||
|
||||
/**
|
||||
* Subclass of Dish where `get` and `_translate` are synchronous.
|
||||
|
@ -32,11 +31,17 @@ class SyncDish extends Dish {
|
|||
}
|
||||
|
||||
super(inputOrDish, type);
|
||||
}
|
||||
|
||||
// Add operations to make it composable
|
||||
for (const op in ops) {
|
||||
this[op] = () => ops[op](this.value);
|
||||
}
|
||||
/**
|
||||
* Apply the inputted operation to the dish.
|
||||
*
|
||||
* @param {WrappedOperation} operation the operation to perform
|
||||
* @param {*} args - any arguments for the operation
|
||||
* @returns {Dish} a new dish with the result of the operation.
|
||||
*/
|
||||
apply(operation, args=null) {
|
||||
return operation(this.value, args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue