diff options
author | Alexander Early <aearly@fluid.com> | 2015-05-25 15:08:00 -0700 |
---|---|---|
committer | Alexander Early <aearly@fluid.com> | 2015-05-25 15:08:00 -0700 |
commit | 7c7326b3892774641b4258f7207842ee8846fdd2 (patch) | |
tree | 5054eac2b470d74b766f30765d6efae7341b7232 /lib/async.js | |
parent | aba3e0c1af87f0f89bbddb6d3a2c56ffb9176c9b (diff) | |
download | async-ensure_async.tar.gz |
use ensureAsync with forever. Fixes #622ensure_async
Diffstat (limited to 'lib/async.js')
-rw-r--r-- | lib/async.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/async.js b/lib/async.js index 06ede14..b8c001b 100644 --- a/lib/async.js +++ b/lib/async.js @@ -1255,14 +1255,13 @@ async.applyEachSeries = doSeries(_applyEach); async.forever = function (fn, callback) { + var done = only_once(callback || noop); + var task = ensureAsync(fn); function next(err) { if (err) { - if (callback) { - return callback(err); - } - throw err; + return done(err); } - fn(next); + task(next); } next(); }; |