[Pkg-javascript-commits] [node-async] 110/480: Docs for `forEachLimit`

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-async.

commit dbc702769c0ff930f6d2bf62c53c2afc291d1f77
Author: Joshua Holbrook <josh.holbrook at gmail.com>
Date:   Mon Oct 24 20:16:54 2011 -0700

    Docs for `forEachLimit`
---
 README.md | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/README.md b/README.md
index 6558bf2..e7fdf5b 100644
--- a/README.md
+++ b/README.md
@@ -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)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git



More information about the Pkg-javascript-commits mailing list