summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorU-Zyn Chua <chua@uzyn.com>2015-06-28 15:51:36 +0800
committerU-Zyn Chua <chua@uzyn.com>2015-06-28 15:51:36 +0800
commit4ec75498d18b72893b20a5b617ec817d7bb8da17 (patch)
tree6eb31f69694379bf5d351e141909e675ceeee0ac /README.md
parentd599c38c9b0617395e526a9e36df3045a81fc262 (diff)
downloadasync-4ec75498d18b72893b20a5b617ec817d7bb8da17.tar.gz
Documentation for during and doDuring.
Diffstat (limited to 'README.md')
-rw-r--r--README.md38
1 files changed, 38 insertions, 0 deletions
diff --git a/README.md b/README.md
index 0197f15..eca7e1b 100644
--- a/README.md
+++ b/README.md
@@ -192,6 +192,8 @@ Usage:
* [`doWhilst`](#doWhilst)
* [`until`](#until)
* [`doUntil`](#doUntil)
+* [`during`](#during)
+* [`doDuring`](#doDuring)
* [`forever`](#forever)
* [`waterfall`](#waterfall)
* [`compose`](#compose)
@@ -991,6 +993,42 @@ Like [`doWhilst`](#doWhilst), except the `test` is inverted. Note the argument o
---------------------------------------
+<a name="during" />
+### during(test, fn, callback)
+
+Like [`whilst`](#whilst), except the `test` is an asynchronous function that is passed a callback in the form of `function (err, truth)`. If error is passed to `test` or `fn`, the main callback is immediately called with the value of the error.
+
+__Example__
+
+```js
+var count = 0;
+
+async.during(
+ function (callback) {
+ return callback(null, count < 5);
+ },
+ function (callback) {
+ count++;
+ setTimeout(callback, 1000);
+ },
+ function (err) {
+ // 5 seconds have passed
+ }
+);
+```
+
+---------------------------------------
+
+<a name="doDuring" />
+### doDuring(fn, test, callback)
+
+The post-check version of [`during`](#during). To reflect the difference in
+the order of operations, the arguments `test` and `fn` are switched.
+
+Also a version of [`doWhilst`](#doWhilst) with asynchronous `test` function.
+
+---------------------------------------
+
<a name="forever" />
### forever(fn, [errback])