refactor: fix incorrect comments in lib/plugins/pipeline.js

This commit is contained in:
Pierre Vanduynslager 2018-07-07 00:05:42 -04:00
parent d3032868d8
commit 12de6282dd

View File

@ -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
);