mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-22 07:46:16 -04:00
improve some comments, remove unused properties from magic state shim in node API
This commit is contained in:
parent
53e69835ff
commit
4dafa50799
4 changed files with 16 additions and 15 deletions
|
@ -24,8 +24,11 @@ class NodeRecipe {
|
|||
|
||||
|
||||
/**
|
||||
* Validate an ingredient $ coerce to operation if necessary.
|
||||
* Validate an ingredient & coerce to operation if necessary.
|
||||
* @param {String | Function | Object} ing
|
||||
* @returns {Function || Object} The operation, or an object with the
|
||||
* operation and its arguments
|
||||
* @throws {TypeError} If it cannot find the operation in chef's list of operations.
|
||||
*/
|
||||
_validateIngredient(ing) {
|
||||
// CASE operation name given. Find operation and validate
|
||||
|
@ -34,6 +37,7 @@ class NodeRecipe {
|
|||
return sanitise(op.opName) === sanitise(ing);
|
||||
});
|
||||
if (op) {
|
||||
// Need to validate against case 2
|
||||
return this._validateIngredient(op);
|
||||
} else {
|
||||
throw new TypeError(`Couldn't find an operation with name '${ing}'.`);
|
||||
|
@ -41,7 +45,7 @@ class NodeRecipe {
|
|||
// CASE operation given. Check its a chef operation and check its not flowcontrol
|
||||
} else if (typeof ing === "function") {
|
||||
if (ing.flowControl) {
|
||||
throw new TypeError(`flowControl operations like ${ing.opName} are not currently allowed in recipes for chef.bake`);
|
||||
throw new TypeError(`flowControl operations like ${ing.opName} are not currently allowed in recipes for chef.bake in the Node API`);
|
||||
}
|
||||
|
||||
if (operations.includes(ing)) {
|
||||
|
@ -63,7 +67,7 @@ class NodeRecipe {
|
|||
|
||||
|
||||
/**
|
||||
* Parse config for recipe.
|
||||
* Parse an opList from a recipeConfig and assign it to the recipe's opList.
|
||||
* @param {String | Function | String[] | Function[] | [String | Function]} recipeConfig
|
||||
*/
|
||||
_parseConfig(recipeConfig) {
|
||||
|
|
|
@ -194,17 +194,14 @@ export function _wrap(OpClass) {
|
|||
const {transformedInput, transformedArgs} = prepareOp(opInstance, input, args);
|
||||
|
||||
// SPECIAL CASE for Magic. Other flowControl operations will
|
||||
// not work because the opList is not passed through.
|
||||
// not work because the opList is not passed in.
|
||||
if (isFlowControl) {
|
||||
opInstance.ingValues = transformedArgs;
|
||||
|
||||
const state = {
|
||||
"progress": 0,
|
||||
"dish": ensureIsDish(transformedInput),
|
||||
"opList": [opInstance],
|
||||
"numJumps": 0,
|
||||
"numRegisters": 0,
|
||||
"forkOffset": 0
|
||||
progress: 0,
|
||||
dish: ensureIsDish(transformedInput),
|
||||
opList: [opInstance],
|
||||
};
|
||||
|
||||
const updatedState = await opInstance.run(state);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue