source: trip-planner-front/node_modules/async/retryable.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[6a3a178]1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7exports.default = function (opts, task) {
8 if (!task) {
9 task = opts;
10 opts = null;
11 }
12 var _task = (0, _wrapAsync2.default)(task);
13 return (0, _initialParams2.default)(function (args, callback) {
14 function taskFn(cb) {
15 _task.apply(null, args.concat(cb));
16 }
17
18 if (opts) (0, _retry2.default)(opts, taskFn, callback);else (0, _retry2.default)(taskFn, callback);
19 });
20};
21
22var _retry = require('./retry');
23
24var _retry2 = _interopRequireDefault(_retry);
25
26var _initialParams = require('./internal/initialParams');
27
28var _initialParams2 = _interopRequireDefault(_initialParams);
29
30var _wrapAsync = require('./internal/wrapAsync');
31
32var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
33
34function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
36module.exports = exports['default'];
37
38/**
39 * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method
40 * wraps a task and makes it retryable, rather than immediately calling it
41 * with retries.
42 *
43 * @name retryable
44 * @static
45 * @memberOf module:ControlFlow
46 * @method
47 * @see [async.retry]{@link module:ControlFlow.retry}
48 * @category Control Flow
49 * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
50 * options, exactly the same as from `retry`
51 * @param {AsyncFunction} task - the asynchronous function to wrap.
52 * This function will be passed any arguments passed to the returned wrapper.
53 * Invoked with (...args, callback).
54 * @returns {AsyncFunction} The wrapped function, which when invoked, will
55 * retry on an error, based on the parameters specified in `opts`.
56 * This function will accept the same parameters as `task`.
57 * @example
58 *
59 * async.auto({
60 * dep1: async.retryable(3, getFromFlakyService),
61 * process: ["dep1", async.retryable(3, function (results, cb) {
62 * maybeProcessData(results.dep1, cb);
63 * })]
64 * }, callback);
65 */
Note: See TracBrowser for help on using the repository browser.