From 4ffed0451258ec1b1a95e911ee84a6a426cc5321 Mon Sep 17 00:00:00 2001 From: Brian Maissy Date: Sun, 3 Mar 2013 00:50:47 +0200 Subject: calling waterfall with a non-array first argument results in an error --- lib/async.js | 4 ++++ test/test-async.js | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/lib/async.js b/lib/async.js index a805447..2ec1934 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 1caf1bc..62e0643 100755 --- a/test/test-async.js +++ b/test/test-async.js @@ -360,6 +360,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();}, -- cgit v1.2.1