Skip to content

Commit

Permalink
refactor: fix incorrect comments in lib/plugins/pipeline.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Jul 10, 2018
1 parent d303286 commit 12de628
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/plugins/pipeline.js
Expand Up @@ -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.
Expand All @@ -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) {
Expand All @@ -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
);
Expand Down

0 comments on commit 12de628

Please sign in to comment.