refactor: always return an Array of results/errors from a plugin pipeline

Always return an `Array` from a pipeline simplify the function utilization as it's more deterministic. Previously, it would return/throw a single value/error when called with a single input and an `Array` of results/errors when called with an `Array` of input.
This commit is contained in:
Pierre Vanduynslager
2018-07-10 13:18:58 -04:00
parent cac48823f1
commit ed9c456f5e
4 changed files with 10 additions and 31 deletions
+2 -2
View File
@@ -49,7 +49,7 @@ module.exports = steps => async (input, {settleAll = false, getNextInput = ident
input
);
if (errors.length > 0) {
throw errors.length === 1 ? errors[0] : new AggregateError(errors);
throw new AggregateError(errors);
}
return results.length <= 1 ? results[0] : results;
return results;
};