diff options
author | Calvin French-Owen <calvin@segment.io> | 2012-11-20 17:44:49 -0800 |
---|---|---|
committer | Calvin French-Owen <calvin@segment.io> | 2012-11-20 17:44:49 -0800 |
commit | 49c7fd7d46e50444889dab174a785d87d2b70cd2 (patch) | |
tree | 1d32e75d2a55e3f7a41e025ef36463415359c9e0 /README.md | |
parent | 96a7da519adc9e8cb3c187a2da4945f5edea71d3 (diff) | |
download | async-49c7fd7d46e50444889dab174a785d87d2b70cd2.tar.gz |
Adding mapLimit
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -226,6 +226,35 @@ processing. The results array will be in the same order as the original. --------------------------------------- +<a name="mapLimit" /> +### mapLimit(arr, limit, iterator, callback) + +The same as map 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. + If no error has occured, the callback should be run without arguments or + with an explicit null argument. +* callback(err, results) - A callback which is called after all the iterator + functions have finished, or an error has occurred. Results is an array of the + transformed items from the original array. + +__Example__ + +```js +async.map(['file1','file2','file3'], 1, fs.stat, function(err, results){ + // results is now an array of stats for each file +}); +``` + +--------------------------------------- + <a name="filter" /> ### filter(arr, iterator, callback) |