summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/async.js4
-rwxr-xr-xtest/test-async.js13
3 files changed, 18 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8998530..65b27dd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
New Features:
- `retry` now accepts an `interval` parameter to specify a delay between retries. (#793)
- `async` should work better in Web Workers due to better `root` detection (#804)
+- Callbacks are now optional in `whilst`, `doWhilst`, `until`, and `doUntil` (#642)
- Various internal updates (#786, #801, #802, #803)
- Various doc fixes (#790, #794)
diff --git a/lib/async.js b/lib/async.js
index 41d33cb..4c638ef 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -785,6 +785,7 @@
async.concatSeries = doSeries(_concat);
async.whilst = function (test, iterator, callback) {
+ callback = callback || noop;
if (test()) {
iterator(function (err) {
if (err) {
@@ -799,6 +800,7 @@
};
async.doWhilst = function (iterator, test, callback) {
+ callback = callback || noop;
iterator(function (err) {
if (err) {
return callback(err);
@@ -814,6 +816,7 @@
};
async.until = function (test, iterator, callback) {
+ callback = callback || noop;
if (!test()) {
iterator(function (err) {
if (err) {
@@ -828,6 +831,7 @@
};
async.doUntil = function (iterator, test, callback) {
+ callback = callback || noop;
iterator(function (err) {
if (err) {
return callback(err);
diff --git a/test/test-async.js b/test/test-async.js
index 11685df..52e6a17 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -2847,6 +2847,19 @@ exports['doWhilst callback params'] = function (test) {
);
};
+exports['whilst optional callback'] = function (test) {
+ var counter = 0;
+ async.whilst(
+ function () { return counter < 2; },
+ function (cb) {
+ counter++;
+ cb();
+ }
+ );
+ test.equal(counter, 2);
+ test.done();
+};
+
exports['queue'] = {
'queue': function (test) {