[Pkg-javascript-commits] [node-async] 05/480: don't pass callback to last function in waterfall chain
Jonas Smedegaard
js at moszumanska.debian.org
Fri May 2 08:58:06 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 99ffdb9110772e4d86816af14ebef2184dfb6c2e
Author: Caolan McMahon <caolan at caolanmcmahon.com>
Date: Thu May 13 20:29:21 2010 +0100
don't pass callback to last function in waterfall chain
---
lib/async.js | 5 ++++-
test/test-async.js | 4 +++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/async.js b/lib/async.js
index 518f4e7..ad4dd77 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -55,7 +55,10 @@ exports.waterfall = function(arr){
i++;
if(i < arr.length){
var args = Array.prototype.slice.call(arguments);
- arr[i].apply(null, args.concat(arguments.callee));
+ if(i < arr.length-1){
+ args = args.concat(arguments.callee)
+ }
+ arr[i].apply(null, args);
}
})();
};
diff --git a/test/test-async.js b/test/test-async.js
index 4af23ef..cad8c64 100644
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -51,7 +51,7 @@ exports.testAuto = function(test){
};
exports.testWaterfall = function(test){
- test.expect(6);
+ test.expect(7);
var call_order = [];
async.waterfall([
function(callback){
@@ -74,6 +74,8 @@ exports.testWaterfall = function(test){
function(arg4, callback){
call_order.push('fn4');
test.same(call_order, ['fn1','fn2','fn3','fn4']);
+ // don't pass callback to last in waterfall chain
+ test.ok(callback === undefined);
test.done();
}
]);
--
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