From 12de6282dd53de58c9ba16d878d90d0867e4045a Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Sat, 7 Jul 2018 00:05:42 -0400 Subject: [PATCH] refactor: fix incorrect comments in `lib/plugins/pipeline.js` --- lib/plugins/pipeline.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/plugins/pipeline.js b/lib/plugins/pipeline.js index 8e731d20f4..ac29c03589 100644 --- a/lib/plugins/pipeline.js +++ b/lib/plugins/pipeline.js @@ -10,7 +10,7 @@ const {extractErrors} = require('../utils'); * @param {Any} input Argument to pass to the first step in the pipeline. * @param {Object} options Pipeline options. * @param {Boolean} [options.settleAll=false] If `true` all the steps in the pipeline are executed, even if one rejects, if `false` the execution stops after a steps rejects. - * @param {Function} [options.getNextInput=identity] Function called after each step is executed, with the last and current step results; the returned value will be used as the argument of the next step. + * @param {Function} [options.getNextInput=identity] Function called after each step is executed, with the last step input and the current current step result; the returned value will be used as the input of the next step. * @param {Function} [options.transform=identity] Function called after each step is executed, with the current step result and the step function; the returned value will be saved in the pipeline results. * * @return {Array<*>|*} An Array with the result of each step in the pipeline; if there is only 1 step in the pipeline, the result of this step is returned directly. @@ -29,11 +29,11 @@ module.exports = steps => async (input, {settleAll = false, getNextInput = ident const errors = []; await pReduce( steps, - async (lastResult, step) => { + async (lastInput, step) => { let result; try { // Call the step with the input computed at the end of the previous iteration and save intermediary result - result = await transform(await step(lastResult), step); + result = await transform(await step(lastInput), step); results.push(result); } catch (err) { if (settleAll) { @@ -43,8 +43,8 @@ module.exports = steps => async (input, {settleAll = false, getNextInput = ident throw err; } } - // Prepare input for the next step, passing the result of the last iteration (or initial parameter for the first iteration) and the current one - return getNextInput(lastResult, result); + // Prepare input for the next step, passing the input of the last iteration (or initial parameter for the first iteration) and the result of the current one + return getNextInput(lastInput, result); }, input );