Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix sync calling of callbacks in waterfall

  • Loading branch information...
commit 10b2ad05a65772a07a94c4c9027e4f24e89b7e64 1 parent 39e0958
@caolan authored
Showing with 3 additions and 3 deletions.
  1. +2 −2 lib/async.js
  2. +1 −1  test/test-async.js
View
4 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++;
}
})();
};
View
2  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');
Please sign in to comment.
Something went wrong with that request. Please try again.