[Pkg-javascript-commits] [node-async] 377/480: Added a little more description to 'forever'

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:44 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 eea14ed194dff46540eee196400acdfc0c8b7480
Author: kybernetikos <me at kybernetikos.com>
Date:   Wed Feb 12 14:06:17 2014 +0000

    Added a little more description to 'forever'
    
    The forever section is unclear at present because there are two callback functions in play (the second argument in forever, and the first argument for fn), and also because it's not made clear that execution will stop if next is not called or if next is called with an argument.
    
    This change is my suggestion to make it a little clearer.
---
 README.md | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 951f76e..02a4877 100644
--- a/README.md
+++ b/README.md
@@ -800,11 +800,26 @@ Like doWhilst except the test is inverted. Note the argument ordering differs fr
 ---------------------------------------
 
 <a name="forever" />
-### forever(fn, callback)
+### forever(fn, errback)
 
-Calls the asynchronous function 'fn' repeatedly, in series, indefinitely.
-If an error is passed to fn's callback then 'callback' is called with the
-error, otherwise it will never be called.
+Calls the asynchronous function 'fn' with a callback parameter that allows it to
+call itself again, in series, indefinitely.
+
+If an error is passed to the callback then 'errback' is called with the
+error, and execution stops, otherwise it will never be called.
+
+```js
+async.forever(
+    function(next) {
+        // next is suitable for passing to things that need a callback(err [, whatever]);
+        // it will result in this function being called again.
+    },
+    function(err) {
+        // if next is called with a value in its first parameter, it will appear
+        // in here as 'err', and execution will stop.
+    }
+);
+```
 
 ---------------------------------------
 

-- 
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