summaryrefslogtreecommitdiff
path: root/lib/forever.js
diff options
context:
space:
mode:
authorAlex Early <alexander.early@gmail.com>2017-04-02 15:23:08 -0700
committerGitHub <noreply@github.com>2017-04-02 15:23:08 -0700
commit49119a895d64991375d1a7b82b3a4d71e3ec8681 (patch)
tree6eb966f6115913e2820e173d2b5ddaa58feb04ac /lib/forever.js
parent66b3c727762e4bf4909e6d8c5e6312810b384204 (diff)
parent8faed87d71496776c7100dc29f2a8e294261c820 (diff)
downloadasync-49119a895d64991375d1a7b82b3a4d71e3ec8681.tar.gz
Merge pull request #1390 from caolan/async-fn-support
`async` function support
Diffstat (limited to 'lib/forever.js')
-rw-r--r--lib/forever.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/forever.js b/lib/forever.js
index 0147395..f7be0b2 100644
--- a/lib/forever.js
+++ b/lib/forever.js
@@ -2,21 +2,22 @@ import noop from 'lodash/noop';
import onlyOnce from './internal/onlyOnce';
import ensureAsync from './ensureAsync';
+import wrapAsync from './internal/wrapAsync';
/**
* 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.
+ * If an error is passed to the callback then `errback` is called with the
+ * error, and execution stops, otherwise it will never be called.
*
* @name forever
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
- * @param {Function} fn - a function to call repeatedly. Invoked with (next).
+ * @param {AsyncFunction} fn - an async function to call repeatedly.
+ * Invoked with (next).
* @param {Function} [errback] - when `fn` passes an error to it's callback,
* this function will be called, and execution stops. Invoked with (err).
* @example
@@ -34,7 +35,7 @@ import ensureAsync from './ensureAsync';
*/
export default function forever(fn, errback) {
var done = onlyOnce(errback || noop);
- var task = ensureAsync(fn);
+ var task = wrapAsync(ensureAsync(fn));
function next(err) {
if (err) return done(err);