浏览代码

ESM: Tidied up FlowControl ops

n1474335 7 年之前
父节点
当前提交
28b24b725f

+ 0 - 2
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}

+ 0 - 3
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;
-
     }
 
 }

+ 1 - 6
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) {

+ 1 - 5
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;

+ 2 - 6
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;
-
     }
 
 }

+ 1 - 3
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.

+ 0 - 2
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.

+ 1 - 5
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";

+ 0 - 2
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.