[Pkg-javascript-commits] [node-async] 182/480: fix occasional synchronous use of forEachLimit
Jonas Smedegaard
js at moszumanska.debian.org
Fri May 2 08:58:24 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 16b9271e5c684cd7729fa3906032536509e3a4a0
Author: Caolan McMahon <caolan at caolanmcmahon.com>
Date: Thu May 24 00:12:42 2012 -0700
fix occasional synchronous use of forEachLimit
---
lib/async.js | 4 ++--
test/test-async.js | 12 ++++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/lib/async.js b/lib/async.js
index 7021df3..3010bab 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -139,7 +139,8 @@
}
while (running < limit && started < arr.length) {
- iterator(arr[started], function (err) {
+ started += 1;
+ iterator(arr[started - 1], function (err) {
if (err) {
callback(err);
callback = function () {};
@@ -155,7 +156,6 @@
}
}
});
- started += 1;
running += 1;
}
})();
diff --git a/test/test-async.js b/test/test-async.js
index ff4b749..ac45272 100644
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -635,6 +635,18 @@ exports['forEachLimit no callback'] = function(test){
async.forEachLimit([1], 1, forEachNoCallbackIterator.bind(this, test));
};
+exports['forEachLimit synchronous'] = function(test){
+ var args = [];
+ var arr = [0,1,2];
+ async.forEachLimit(arr, 5, function(x,callback){
+ args.push(x);
+ callback();
+ }, function(err){
+ test.same(args, arr);
+ test.done();
+ });
+};
+
exports['map'] = function(test){
var call_order = [];
async.map([1,3,2], mapIterator.bind(this, call_order), function(err, results){
--
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