[Pkg-javascript-commits] [node-async] 186/480: Imported Upstream version 0.1.21
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 122be31de3bbd9997993d8daa267e9eaefcc096c
Author: Jonas Smedegaard <dr at jones.dk>
Date: Thu May 24 16:44:04 2012 +0200
Imported Upstream version 0.1.21
---
dist/async.min.js | 2 +-
lib/async.js | 60 +++++++++++++++++++++++++++---------------------------
package.json | 2 +-
test/test-async.js | 12 +++++++++++
4 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/dist/async.min.js b/dist/async.min.js
index 53e457c..af28086 100644
--- a/dist/async.min.js
+++ b/dist/async.min.js
@@ -1 +1 @@
-/*global setTimeout: false, console: false */(function(){var a={},b=this,c=b.async;typeof module!="undefined"&&module.exports?module.exports=a:b.async=a,a.noConflict=function(){return b.async=c,a};var d=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c<a.length;c+=1)b(a[c],c,a)},e=function(a,b){if(a.map)return a.map(b);var c=[];return d(a,function(a,d,e){c.push(b(a,d,e))}),c},f=function(a,b,c){return a.reduce?a.reduce(b,c):(d(a,function(a,d,e){c=b(c,a,d,e)}),c)},g=function(a){ [...]
\ No newline at end of file
+/*global setTimeout: false, console: false */(function(){var a={},b=this,c=b.async;typeof module!="undefined"&&module.exports?module.exports=a:b.async=a,a.noConflict=function(){return b.async=c,a};var d=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c<a.length;c+=1)b(a[c],c,a)},e=function(a,b){if(a.map)return a.map(b);var c=[];return d(a,function(a,d,e){c.push(b(a,d,e))}),c},f=function(a,b,c){return a.reduce?a.reduce(b,c):(d(a,function(a,d,e){c=b(c,a,d,e)}),c)},g=function(a){ [...]
\ No newline at end of file
diff --git a/lib/async.js b/lib/async.js
index 52276d6..4a51d28 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -91,7 +91,7 @@
else {
completed += 1;
if (completed === arr.length) {
- callback();
+ callback(null);
}
}
});
@@ -113,7 +113,7 @@
else {
completed += 1;
if (completed === arr.length) {
- callback();
+ callback(null);
}
else {
iterate();
@@ -123,41 +123,41 @@
};
iterate();
};
-
+
async.forEachLimit = function (arr, limit, iterator, callback) {
callback = callback || function () {};
if (!arr.length || limit <= 0) {
- return callback();
+ return callback();
}
var completed = 0;
var started = 0;
var running = 0;
-
+
(function replenish () {
- if (completed === arr.length) {
- return callback();
- }
-
- while (running < limit && started < arr.length) {
- iterator(arr[started], function (err) {
- if (err) {
- callback(err);
- callback = function () {};
- }
- else {
- completed += 1;
- running -= 1;
- if (completed === arr.length) {
- callback();
- }
- else {
- replenish();
- }
- }
- });
- started += 1;
- running += 1;
- }
+ if (completed === arr.length) {
+ return callback();
+ }
+
+ while (running < limit && started < arr.length) {
+ started += 1;
+ running += 1;
+ iterator(arr[started - 1], function (err) {
+ if (err) {
+ callback(err);
+ callback = function () {};
+ }
+ else {
+ completed += 1;
+ running -= 1;
+ if (completed === arr.length) {
+ callback();
+ }
+ else {
+ replenish();
+ }
+ }
+ });
+ }
})();
};
@@ -686,7 +686,7 @@
async.unmemoize = function (fn) {
return function () {
return (fn.unmemoized || fn).apply(null, arguments);
- }
+ };
};
}());
diff --git a/package.json b/package.json
index 5679bec..5d27e10 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
, "description": "Higher-order functions and common patterns for asynchronous code"
, "main": "./index"
, "author": "Caolan McMahon"
-, "version": "0.1.18"
+, "version": "0.1.21"
, "repository" :
{ "type" : "git"
, "url" : "http://github.com/caolan/async.git"
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