diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/waterfall.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/waterfall.js b/lib/waterfall.js index e25f629..a31b3b4 100644 --- a/lib/waterfall.js +++ b/lib/waterfall.js @@ -15,21 +15,20 @@ export default function(tasks, cb) { function nextTask(args) { if (taskIndex === tasks.length) { - return cb.apply(null, [null].concat(args)); + return cb(null, ...args); } - var task = tasks[taskIndex]; - taskIndex++; var taskCallback = onlyOnce(rest(function(err, args) { if (err) { - return cb.apply(null, [err].concat(args)); + return cb(err, ...args); } nextTask(args); })); args.push(taskCallback); - task.apply(null, args); + var task = tasks[taskIndex++]; + task(...args); } nextTask([]); |