ESM: Tidied up FlowControl ops

This commit is contained in:
n1474335 2018-05-21 11:39:10 +00:00
parent 1472f82205
commit 28b24b725f
9 changed files with 6 additions and 34 deletions

View File

@ -4,13 +4,11 @@
* @author d98762625 [d98762625@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*
*/
/**
* Returns the index of a label.
*
* @private
* @param {Object} state - The current state of the recipe.
* @param {string} name - The label name to look for.
* @returns {number}

View File

@ -33,8 +33,6 @@ class Comment extends Operation {
}
/**
* Comment operation.
*
* @param {Object} state - The current state of the recipe.
* @param {number} state.progress - The current position in the recipe.
* @param {Dish} state.dish - The Dish being operated on.
@ -43,7 +41,6 @@ class Comment extends Operation {
*/
run(state) {
return state;
}
}

View File

@ -50,8 +50,6 @@ class ConditionalJump extends Operation {
}
/**
* Conditional Jump operation.
*
* @param {Object} state - The current state of the recipe.
* @param {number} state.progress - The current position in the recipe.
* @param {Dish} state.dish - The Dish being operated on.
@ -62,10 +60,7 @@ class ConditionalJump extends Operation {
async run(state) {
const ings = state.opList[state.progress].ingValues,
dish = state.dish,
regexStr = ings[0],
invert = ings[1],
label = ings[2],
maxJumps = ings[3],
[regexStr, invert, label, maxJumps] = ings,
jmpIndex = getLabelIndex(label, state);
if (state.numJumps >= maxJumps || jmpIndex === -1) {

View File

@ -45,8 +45,6 @@ class Fork extends Operation {
}
/**
* Fork operation.
*
* @param {Object} state - The current state of the recipe.
* @param {number} state.progress - The current position in the recipe.
* @param {Dish} state.dish - The Dish being operated on.
@ -59,9 +57,7 @@ class Fork extends Operation {
outputType = opList[state.progress].outputType,
input = await state.dish.get(inputType),
ings = opList[state.progress].ingValues,
splitDelim = ings[0],
mergeDelim = ings[1],
ignoreErrors = ings[2],
[splitDelim, mergeDelim, ignoreErrors] = ings,
subOpList = [];
let inputs = [],
i;

View File

@ -39,8 +39,6 @@ class Jump extends Operation {
}
/**
* Jump operation.
*
* @param {Object} state - The current state of the recipe.
* @param {number} state.progress - The current position in the recipe.
* @param {Dish} state.dish - The Dish being operated on.
@ -49,9 +47,8 @@ class Jump extends Operation {
* @returns {Object} The updated state of the recipe.
*/
run(state) {
const ings = state.opList[state.progress].ingValues;
const label = ings[0];
const maxJumps = ings[1];
const ings = state.opList[state.progress].ingValues;
const [label, maxJumps] = ings;
const jmpIndex = getLabelIndex(label, state);
if (state.numJumps >= maxJumps || jmpIndex === -1) {
@ -61,7 +58,6 @@ class Jump extends Operation {
state.progress = jmpIndex;
state.numJumps++;
return state;
}
}

View File

@ -7,7 +7,7 @@
import Operation from "../Operation";
/**
* Label operation
* Label operation. For use with Jump and Conditional Jump.
*/
class Label extends Operation {
@ -33,8 +33,6 @@ class Label extends Operation {
}
/**
* Label operation. For use with Jump and Conditional Jump
*
* @param {Object} state - The current state of the recipe.
* @param {number} state.progress - The current position in the recipe.
* @param {Dish} state.dish - The Dish being operated on.

View File

@ -27,8 +27,6 @@ class Merge extends Operation {
}
/**
* Merge operation.
*
* @param {Object} state - The current state of the recipe.
* @param {number} state.progress - The current position in the recipe.
* @param {Dish} state.dish - The Dish being operated on.

View File

@ -44,8 +44,6 @@ class Register extends Operation {
}
/**
* Register operation.
*
* @param {Object} state - The current state of the recipe.
* @param {number} state.progress - The current position in the recipe.
* @param {Dish} state.dish - The Dish being operated on.
@ -54,9 +52,7 @@ class Register extends Operation {
*/
async run(state) {
const ings = state.opList[state.progress].ingValues;
const extractorStr = ings[0];
const i = ings[1];
const m = ings[2];
const [extractorStr, i, m] = ings;
let modifiers = "";
if (i) modifiers += "i";

View File

@ -27,8 +27,6 @@ class Return extends Operation {
}
/**
* Return operation.
*
* @param {Object} state - The current state of the recipe.
* @param {number} state.progress - The current position in the recipe.
* @param {Dish} state.dish - The Dish being operated on.