Sha256: 1b689d19c5fae0051610850af1083ff4f61b5ec72708e2f493dd7dc145436af0

Contents?: true

Size: 1.98 KB

Versions: 48

Compression:

Stored size: 1.98 KB

Contents

'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});

exports.default = function (opts, task) {
    if (!task) {
        task = opts;
        opts = null;
    }
    var _task = (0, _wrapAsync2.default)(task);
    return (0, _initialParams2.default)(function (args, callback) {
        function taskFn(cb) {
            _task.apply(null, args.concat(cb));
        }

        if (opts) (0, _retry2.default)(opts, taskFn, callback);else (0, _retry2.default)(taskFn, callback);
    });
};

var _retry = require('./retry');

var _retry2 = _interopRequireDefault(_retry);

var _initialParams = require('./internal/initialParams');

var _initialParams2 = _interopRequireDefault(_initialParams);

var _wrapAsync = require('./internal/wrapAsync');

var _wrapAsync2 = _interopRequireDefault(_wrapAsync);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

module.exports = exports['default'];

/**
 * 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
 * @memberOf module:ControlFlow
 * @method
 * @see [async.retry]{@link module:ControlFlow.retry}
 * @category Control Flow
 * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
 * options, exactly the same as from `retry`
 * @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({
 *     dep1: async.retryable(3, getFromFlakyService),
 *     process: ["dep1", async.retryable(3, function (results, cb) {
 *         maybeProcessData(results.dep1, cb);
 *     })]
 * }, callback);
 */

Version data entries

48 entries across 46 versions & 11 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/async/retryable.js
disco_app-0.18.0 test/dummy/node_modules/async/retryable.js
disco_app-0.18.2 test/dummy/node_modules/async/retryable.js
disco_app-0.16.1 test/dummy/node_modules/async/retryable.js
disco_app-0.15.2 test/dummy/node_modules/async/retryable.js
disco_app-0.18.4 test/dummy/node_modules/async/retryable.js
disco_app-0.18.1 test/dummy/node_modules/async/retryable.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/async/retryable.js
disco_app-0.14.0 test/dummy/node_modules/async/retryable.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/async/retryable.js
tang-0.2.1 spec/tang_app/node_modules/async/retryable.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/async/retryable.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/async/retryable.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/async/retryable.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/async/retryable.js
tang-0.2.0 spec/tang_app/node_modules/async/retryable.js
tang-0.1.0 spec/tang_app/node_modules/async/retryable.js
tang-0.0.9 spec/tang_app/node_modules/async/retryable.js
enju_library-0.3.8 spec/dummy/node_modules/async/retryable.js
ilog-0.4.1 node_modules/async/retryable.js