summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraeme Yeates <yeatesgraeme@gmail.com>2015-07-02 11:28:52 -0400
committerGraeme Yeates <yeatesgraeme@gmail.com>2015-07-02 11:28:52 -0400
commitc61e63b357262f627d945bd0f41aeaa02b95c361 (patch)
treec1e6368daea4db01b4e7ec520c563900218676e4
parent06813bffd737a183d01e0fa89d70a31635019676 (diff)
downloadasync-c61e63b357262f627d945bd0f41aeaa02b95c361.tar.gz
Add everyLimit
-rw-r--r--lib/async.js2
-rwxr-xr-xtest/test-async.js18
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/async.js b/lib/async.js
index f0e3adf..a914542 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -487,6 +487,8 @@
async.all =
async.every = _createTester(async.eachOf, notId, true);
+ async.everyLimit = _createTester(async.eachOfLimit, notId, true);
+
async.sortBy = function (arr, iterator, callback) {
async.map(arr, function (x, callback) {
iterator(x, function (err, criteria) {
diff --git a/test/test-async.js b/test/test-async.js
index fe94ddc..b7847bf 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -2254,6 +2254,24 @@ exports['someLimit false'] = function(test){
});
};
+exports['every true'] = function(test){
+ async.everyLimit([3,1,2], 1, function(x, callback){
+ setTimeout(function(){callback(x > 1);}, 0);
+ }, function(result){
+ test.equals(result, true);
+ test.done();
+ });
+};
+
+exports['everyLimit false'] = function(test){
+ async.everyLimit([3,1,2], 2, function(x, callback){
+ setTimeout(function(){callback(x === 2);}, 0);
+ }, function(result){
+ test.equals(result, false);
+ test.done();
+ });
+};
+
exports['any alias'] = function(test){
test.equals(async.any, async.some);
test.done();