summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraeme Yeates <yeatesgraeme@gmail.com>2015-07-01 17:07:16 -0400
committerGraeme Yeates <yeatesgraeme@gmail.com>2015-07-01 17:07:16 -0400
commitf0553cff85ad16e6135e4ccbaf7722bc059bd3f6 (patch)
treeb8f16703f113f1e3dc6b4a5e5c8051a223d04ab3
parentc312a050eb8bbbf8826d7ce05781ad99ac14e9dc (diff)
downloadasync-f0553cff85ad16e6135e4ccbaf7722bc059bd3f6.tar.gz
Implement *until via while
-rw-r--r--lib/async.js30
1 files changed, 6 insertions, 24 deletions
diff --git a/lib/async.js b/lib/async.js
index 5da3622..71f9a54 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -819,33 +819,15 @@
};
async.until = function (test, iterator, callback) {
- callback = callback || noop;
- if (!test()) {
- iterator(function (err) {
- if (err) {
- return callback(err);
- }
- async.until(test, iterator, callback);
- });
- }
- else {
- callback(null);
- }
+ return async.whilst(function() {
+ return !test.apply(this, arguments);
+ }, iterator, callback);
};
async.doUntil = function (iterator, test, callback) {
- callback = callback || noop;
- iterator(_restParam(function (err, args) {
- if (err) {
- return callback(err);
- }
- if (!test.apply(null, args)) {
- async.doUntil(iterator, test, callback);
- }
- else {
- callback(null);
- }
- }));
+ return async.doWhilst(iterator, function() {
+ return !test.apply(this, arguments);
+ }, callback);
};
async.during = function (test, iterator, callback) {