diff options
author | Alexander Early <alexander.early@gmail.com> | 2016-03-07 23:46:01 -0800 |
---|---|---|
committer | Alexander Early <alexander.early@gmail.com> | 2016-03-07 23:46:01 -0800 |
commit | a211146f9c67057797fdce69446e1eb765616575 (patch) | |
tree | 45161bd49c18964582ad4c48d4c6413e65cf0361 /lib | |
parent | 831f37f2a27ec262159190fa3165d428010c7813 (diff) | |
download | async-a211146f9c67057797fdce69446e1eb765616575.tar.gz |
added retryable wrapper for async tasks
Diffstat (limited to 'lib')
-rw-r--r-- | lib/index.js | 3 | ||||
-rw-r--r-- | lib/retryable.js | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/index.js b/lib/index.js index 300491d..869ba6e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -49,6 +49,7 @@ import reject from './reject'; import rejectLimit from './rejectLimit'; import rejectSeries from './rejectSeries'; import retry from './retry'; +import retryable from './retryable'; import seq from './seq'; import series from './series'; import setImmediate from './setImmediate'; @@ -115,6 +116,7 @@ export default { rejectLimit: rejectLimit, rejectSeries: rejectSeries, retry: retry, + retryable: retryable, seq: seq, series: series, setImmediate: setImmediate, @@ -199,6 +201,7 @@ export { rejectLimit as rejectLimit, rejectSeries as rejectSeries, retry as retry, + retryable as retryable, seq as seq, series as series, setImmediate as setImmediate, diff --git a/lib/retryable.js b/lib/retryable.js new file mode 100644 index 0000000..5bb3ccd --- /dev/null +++ b/lib/retryable.js @@ -0,0 +1,11 @@ +import retry from './retry'; +import rest from 'lodash/rest'; + +export default function (opts, task) { + return rest(function (args) { + var callback = args.pop(); + retry(opts, function (cb) { + task(...args.concat([cb])); + }, callback); + }); +} |