diff options
author | U-Zyn Chua <chua@uzyn.com> | 2015-06-28 15:51:36 +0800 |
---|---|---|
committer | U-Zyn Chua <chua@uzyn.com> | 2015-06-28 15:51:36 +0800 |
commit | 4ec75498d18b72893b20a5b617ec817d7bb8da17 (patch) | |
tree | 6eb31f69694379bf5d351e141909e675ceeee0ac | |
parent | d599c38c9b0617395e526a9e36df3045a81fc262 (diff) | |
download | async-4ec75498d18b72893b20a5b617ec817d7bb8da17.tar.gz |
Documentation for during and doDuring.
-rw-r--r-- | README.md | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -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]) |