diff options
-rw-r--r-- | lib/retryable.js | 13 | ||||
-rw-r--r-- | mocha_test/retryable.js | 3 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/retryable.js b/lib/retryable.js index 3d73f79..26fa609 100644 --- a/lib/retryable.js +++ b/lib/retryable.js @@ -2,10 +2,19 @@ import retry from './retry'; import rest from 'lodash/rest'; export default function (opts, task) { + if (!task) { + task = opts; + opts = null; + } return rest(function (args) { var callback = args.pop(); - retry(opts, function (cb) { + + function taskFn(cb) { task.apply(null, args.concat([cb])); - }, callback); + } + + if (opts) retry(opts, taskFn, callback); + else retry(taskFn, callback); + }); } diff --git a/mocha_test/retryable.js b/mocha_test/retryable.js index 8cad403..8141629 100644 --- a/mocha_test/retryable.js +++ b/mocha_test/retryable.js @@ -21,8 +21,7 @@ describe('retryable', function () { }, 15); }); - // TODO: re-enable when auto's args are swapped - it.skip('should work as an embedded task', function(done) { + it('should work as an embedded task', function(done) { var retryResult = 'RETRY'; var fooResults; var retryResults; |