Skip to content

Commit

Permalink
Merge pull request #1129 from WaeCo/patch-1
Browse files Browse the repository at this point in the history
Updated description of during #1121
  • Loading branch information
aearly committed Apr 26, 2016
2 parents a50b252 + 5adcc6b commit 1114e65
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -956,18 +956,26 @@ Like [`doWhilst`](#doWhilst), except the `test` is inverted. Note the argument o

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.

Additionaly `during` passes any arguments passed by the iteratee function (2nd function) to the test function (1st function). The test callback will allways be the last parameter.

__Example__

```js
var count = 0;

async.during(
function (callback) {
return callback(null, count < 5);
function (result, callback) {
if(!callback) {
callback = result;
result = null;
}
return callback(null, !result || result.counter < 5);
},
function (callback) {
count++;
setTimeout(callback, 1000);
setTimeout(function() {
callback(null, { counter: count });
}, 1000);
},
function (err) {
// 5 seconds have passed
Expand Down

0 comments on commit 1114e65

Please sign in to comment.