summaryrefslogtreecommitdiff
path: root/lib/retry.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/retry.js')
-rw-r--r--lib/retry.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/retry.js b/lib/retry.js
index 2a353dc..5ef6971 100644
--- a/lib/retry.js
+++ b/lib/retry.js
@@ -1,5 +1,5 @@
-import noop from './internal/noop';
import wrapAsync from './internal/wrapAsync';
+import { promiseCallback, PROMISE_SYMBOL } from './internal/promiseCallback';
function constant(value) {
return function () {
@@ -39,6 +39,7 @@ function constant(value) {
* task has succeeded, or after the final failed attempt. It receives the `err`
* and `result` arguments of the last attempt at completing the `task`. Invoked
* with (err, results).
+ * @returns {Promise} a promise if no callback provided
*
* @example
*
@@ -101,11 +102,11 @@ export default function retry(opts, task, callback) {
};
if (arguments.length < 3 && typeof opts === 'function') {
- callback = task || noop;
+ callback = task || promiseCallback();
task = opts;
} else {
parseTimes(options, opts);
- callback = callback || noop;
+ callback = callback || promiseCallback();
}
if (typeof task !== 'function') {
@@ -129,6 +130,7 @@ export default function retry(opts, task, callback) {
}
retryAttempt();
+ return callback[PROMISE_SYMBOL]
}
function parseTimes(acc, t) {