From 28b24b725fc1ee15336bf7ca2eb73cd965b4a3d3 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Mon, 21 May 2018 11:39:10 +0000 Subject: [PATCH] ESM: Tidied up FlowControl ops --- src/core/lib/FlowControl.mjs | 2 -- src/core/operations/Comment.mjs | 3 --- src/core/operations/ConditionalJump.mjs | 7 +------ src/core/operations/Fork.mjs | 6 +----- src/core/operations/Jump.mjs | 8 ++------ src/core/operations/Label.mjs | 4 +--- src/core/operations/Merge.mjs | 2 -- src/core/operations/Register.mjs | 6 +----- src/core/operations/Return.mjs | 2 -- 9 files changed, 6 insertions(+), 34 deletions(-) diff --git a/src/core/lib/FlowControl.mjs b/src/core/lib/FlowControl.mjs index 0d25511a..56679ece 100644 --- a/src/core/lib/FlowControl.mjs +++ b/src/core/lib/FlowControl.mjs @@ -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} diff --git a/src/core/operations/Comment.mjs b/src/core/operations/Comment.mjs index 7b13ba10..2c941089 100644 --- a/src/core/operations/Comment.mjs +++ b/src/core/operations/Comment.mjs @@ -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; - } } diff --git a/src/core/operations/ConditionalJump.mjs b/src/core/operations/ConditionalJump.mjs index 95343b24..d102ea72 100644 --- a/src/core/operations/ConditionalJump.mjs +++ b/src/core/operations/ConditionalJump.mjs @@ -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) { diff --git a/src/core/operations/Fork.mjs b/src/core/operations/Fork.mjs index 1a527c71..27a1af96 100644 --- a/src/core/operations/Fork.mjs +++ b/src/core/operations/Fork.mjs @@ -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; diff --git a/src/core/operations/Jump.mjs b/src/core/operations/Jump.mjs index 339ead77..30fca5a0 100644 --- a/src/core/operations/Jump.mjs +++ b/src/core/operations/Jump.mjs @@ -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; - } } diff --git a/src/core/operations/Label.mjs b/src/core/operations/Label.mjs index 3d1674bc..1444f3ac 100644 --- a/src/core/operations/Label.mjs +++ b/src/core/operations/Label.mjs @@ -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. diff --git a/src/core/operations/Merge.mjs b/src/core/operations/Merge.mjs index 55b56a41..462660c4 100644 --- a/src/core/operations/Merge.mjs +++ b/src/core/operations/Merge.mjs @@ -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. diff --git a/src/core/operations/Register.mjs b/src/core/operations/Register.mjs index a87b237b..b3a5397f 100644 --- a/src/core/operations/Register.mjs +++ b/src/core/operations/Register.mjs @@ -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"; diff --git a/src/core/operations/Return.mjs b/src/core/operations/Return.mjs index e758a03c..cc83bff8 100644 --- a/src/core/operations/Return.mjs +++ b/src/core/operations/Return.mjs @@ -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.