diff options
| author | Caolan McMahon <caolan@caolanmcmahon.com> | 2011-10-29 15:30:40 -0700 |
|---|---|---|
| committer | Caolan McMahon <caolan@caolanmcmahon.com> | 2011-10-29 15:30:40 -0700 |
| commit | 371530af4c8fe36693a7c651082c0b9e8b935bd4 (patch) | |
| tree | 91b23d29e63accf64f983acf52002c62a250542f | |
| parent | 4608fb3167d518b33b374d3109f87cd1f8313ff9 (diff) | |
| parent | dbc702769c0ff930f6d2bf62c53c2afc291d1f77 (diff) | |
| download | async-371530af4c8fe36693a7c651082c0b9e8b935bd4.tar.gz | |
Merge pull request #63 from jesusabdullah/master
Docs for `forEachLimit`
| -rw-r--r-- | README.md | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -144,6 +144,32 @@ processing. This means the iterator functions will complete in order. --------------------------------------- +<a name="forEachLimit" /> +### forEachLimit(arr, limit, iterator, callback) + +The same as forEach only the iterator is applied to batches of items in the +array, in series. The next batch of iterators is only called once the current +one has completed processing. + +__Arguments__ + +* arr - An array to iterate over. +* limit - How many items should be in each batch. +* iterator(item, callback) - A function to apply to each item in the array. + The iterator is passed a callback which must be called once it has completed. +* callback(err) - A callback which is called after all the iterator functions + have finished, or an error has occurred. + +__Example__ + + // Assume documents is an array of JSON objects and requestApi is a + // function that interacts with a rate-limited REST api. + + async.forEachLimit(documents, 20, requestApi, function(err){ + // if any of the saves produced an error, err would equal that error + }); +--------------------------------------- + <a name="map" /> ### map(arr, iterator, callback) |
