summaryrefslogtreecommitdiff
path: root/lib/retryable.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/retryable.js')
-rw-r--r--lib/retryable.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/retryable.js b/lib/retryable.js
index a541977..5741031 100644
--- a/lib/retryable.js
+++ b/lib/retryable.js
@@ -1,9 +1,11 @@
import retry from './retry';
import initialParams from './internal/initialParams';
+import wrapAsync from './internal/wrapAsync';
/**
- * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method wraps a task and makes it
- * retryable, rather than immediately calling it with retries.
+ * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method
+ * wraps a task and makes it retryable, rather than immediately calling it
+ * with retries.
*
* @name retryable
* @static
@@ -13,9 +15,12 @@ import initialParams from './internal/initialParams';
* @category Control Flow
* @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
* options, exactly the same as from `retry`
- * @param {Function} task - the asynchronous function to wrap
- * @returns {Functions} The wrapped function, which when invoked, will retry on
- * an error, based on the parameters specified in `opts`.
+ * @param {AsyncFunction} task - the asynchronous function to wrap.
+ * This function will be passed any arguments passed to the returned wrapper.
+ * Invoked with (...args, callback).
+ * @returns {AsyncFunction} The wrapped function, which when invoked, will
+ * retry on an error, based on the parameters specified in `opts`.
+ * This function will accept the same parameters as `task`.
* @example
*
* async.auto({
@@ -30,9 +35,10 @@ export default function (opts, task) {
task = opts;
opts = null;
}
+ var _task = wrapAsync(task);
return initialParams(function (args, callback) {
function taskFn(cb) {
- task.apply(null, args.concat(cb));
+ _task.apply(null, args.concat(cb));
}
if (opts) retry(opts, taskFn, callback);