summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Early <alex@npmjs.com>2018-06-10 18:46:45 -0700
committerAlexander Early <alex@npmjs.com>2018-06-10 18:46:45 -0700
commitcccd88961138247a15d026ae51d36705aed3a6d2 (patch)
treeecda512c9f982b37e7933a0974719f642e690610
parent062908b448f3de98fe89aebf27b404f58e116a60 (diff)
downloadasync-cccd88961138247a15d026ae51d36705aed3a6d2.tar.gz
fix waterfall test. It WILL get there
-rw-r--r--lib/waterfall.js6
-rw-r--r--test/waterfall.js4
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/waterfall.js b/lib/waterfall.js
index 10db926..807d2ac 100644
--- a/lib/waterfall.js
+++ b/lib/waterfall.js
@@ -67,6 +67,7 @@ export default function(tasks, callback) {
if (!Array.isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions'));
if (!tasks.length) return callback();
var taskIndex = 0;
+ var canceled = false
function nextTask(args) {
var task = wrapAsync(tasks[taskIndex++]);
@@ -75,7 +76,10 @@ export default function(tasks, callback) {
}
function next(err/*, ...args*/) {
- if (err === false) return // canceled
+ if (err === false || canceled) {
+ canceled = true
+ return
+ }
if (err || taskIndex === tasks.length) {
return callback.apply(null, arguments);
}
diff --git a/test/waterfall.js b/test/waterfall.js
index 8892f04..1501f03 100644
--- a/test/waterfall.js
+++ b/test/waterfall.js
@@ -153,9 +153,7 @@ describe("waterfall", function () {
function(arg1, arg2, callback){
setTimeout(callback, 15, null, arg1, arg2, 'three');
}
- ], function () {
- throw new Error('should not get here')
- });
+ ]);
});
it('call in another context @nycinvalid @nodeonly', function(done) {