[Pkg-javascript-commits] [node-async] 297/480: calling waterfall with a non-array first argument results in an error

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:36 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-async.

commit 4ffed0451258ec1b1a95e911ee84a6a426cc5321
Author: Brian Maissy <brian.maissy at gmail.com>
Date:   Sun Mar 3 00:50:47 2013 +0200

    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();},

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git



More information about the Pkg-javascript-commits mailing list