diff options
author | Caolan McMahon <caolan@caolanmcmahon.com> | 2013-03-11 01:54:56 -0700 |
---|---|---|
committer | Caolan McMahon <caolan@caolanmcmahon.com> | 2013-03-11 01:54:56 -0700 |
commit | bd53939c44f1396bda80c9f5e464cc82db7a4fd1 (patch) | |
tree | 4a480bd61e1aac5d9574d11040e3051adc8db344 | |
parent | 87ce10bc98adbc70ed29dd94c4aa1a309c289ab6 (diff) | |
parent | 4ffed0451258ec1b1a95e911ee84a6a426cc5321 (diff) | |
download | async-bd53939c44f1396bda80c9f5e464cc82db7a4fd1.tar.gz |
Merge pull request #251 from brianmaissy/waterfall
calling waterfall with a non-array first argument results in an error
-rwxr-xr-x | lib/async.js | 4 | ||||
-rwxr-xr-x | test/test-async.js | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/async.js b/lib/async.js index ad3982a..5747dbd 100755 --- a/lib/async.js +++ b/lib/async.js @@ -467,6 +467,10 @@ async.waterfall = function (tasks, callback) { callback = callback || function () {}; + if (tasks.constructor !== Array) { + var err = new Error('First argument to waterfall must be an array of functions'); + return callback(err); + } if (!tasks.length) { return callback(); } diff --git a/test/test-async.js b/test/test-async.js index 5bd72bf..1f0564f 100755 --- a/test/test-async.js +++ b/test/test-async.js @@ -420,6 +420,13 @@ exports['waterfall empty array'] = function(test){ }); }; +exports['waterfall non-array'] = function(test){ + async.waterfall({}, function(err){ + test.equals(err.message, 'First argument to waterfall must be an array of functions'); + test.done(); + }); +}; + exports['waterfall no callback'] = function(test){ async.waterfall([ function(callback){callback();}, |