[Pkg-javascript-commits] [node-async] 04/480: fix sync calling of callbacks in waterfall

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 10b2ad05a65772a07a94c4c9027e4f24e89b7e64
Author: Caolan McMahon <caolan at caolanmcmahon.com>
Date:   Thu May 13 20:22:15 2010 +0100

    fix sync calling of callbacks in waterfall
---
 lib/async.js       | 4 ++--
 test/test-async.js | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/async.js b/lib/async.js
index d7b2efd..518f4e7 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -50,12 +50,12 @@ exports.auto = function(tasks, callback){
 };
 
 exports.waterfall = function(arr){
-    var i = 0;
+    var i = -1;
     (function(){
+        i++;
         if(i < arr.length){
             var args = Array.prototype.slice.call(arguments);
             arr[i].apply(null, args.concat(arguments.callee));
-            i++;
         }
     })();
 };
diff --git a/test/test-async.js b/test/test-async.js
index d6347b1..4af23ef 100644
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -69,7 +69,7 @@ exports.testWaterfall = function(test){
             test.equals(arg1, 'one');
             test.equals(arg2, 'two');
             test.equals(arg3, 'three');
-            process.nextTick(function(){callback('four');});
+            callback('four');
         },
         function(arg4, callback){
             call_order.push('fn4');

-- 
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