diff options
author | Graeme Yeates <yeatesgraeme@gmail.com> | 2015-07-01 17:07:16 -0400 |
---|---|---|
committer | Graeme Yeates <yeatesgraeme@gmail.com> | 2015-07-01 17:07:16 -0400 |
commit | f0553cff85ad16e6135e4ccbaf7722bc059bd3f6 (patch) | |
tree | b8f16703f113f1e3dc6b4a5e5c8051a223d04ab3 | |
parent | c312a050eb8bbbf8826d7ce05781ad99ac14e9dc (diff) | |
download | async-f0553cff85ad16e6135e4ccbaf7722bc059bd3f6.tar.gz |
Implement *until via while
-rw-r--r-- | lib/async.js | 30 |
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) { |