api-def 0.9.1 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +1 -1
  2. package/cjs/Api.d.ts +35 -35
  3. package/cjs/Api.js +140 -144
  4. package/cjs/ApiConstants.d.ts +58 -58
  5. package/cjs/ApiConstants.js +55 -55
  6. package/cjs/ApiTypes.d.ts +103 -103
  7. package/cjs/ApiTypes.js +4 -4
  8. package/cjs/ApiUtils.d.ts +6 -6
  9. package/cjs/ApiUtils.js +51 -53
  10. package/cjs/Endpoint.d.ts +52 -52
  11. package/cjs/Endpoint.js +104 -108
  12. package/cjs/EndpointBuilder.d.ts +14 -14
  13. package/cjs/EndpointBuilder.js +46 -46
  14. package/cjs/MockingTypes.d.ts +30 -30
  15. package/cjs/MockingTypes.js +2 -2
  16. package/cjs/QueryHandling.d.ts +3 -3
  17. package/cjs/QueryHandling.js +24 -24
  18. package/cjs/RequestConfig.d.ts +2 -2
  19. package/cjs/RequestConfig.js +74 -74
  20. package/cjs/RequestContext.d.ts +48 -48
  21. package/cjs/RequestContext.js +235 -238
  22. package/cjs/RequestError.d.ts +30 -30
  23. package/cjs/RequestError.js +47 -47
  24. package/cjs/Requester.d.ts +3 -3
  25. package/cjs/Requester.js +335 -336
  26. package/cjs/TextDecoding.d.ts +1 -1
  27. package/cjs/TextDecoding.js +152 -139
  28. package/cjs/UtilTypes.d.ts +5 -5
  29. package/cjs/UtilTypes.js +2 -2
  30. package/cjs/Utils.d.ts +15 -15
  31. package/cjs/Utils.js +79 -77
  32. package/cjs/Validation.d.ts +8 -8
  33. package/cjs/Validation.js +2 -2
  34. package/cjs/backend/AxiosRequestBackend.d.ts +13 -13
  35. package/cjs/backend/AxiosRequestBackend.js +99 -99
  36. package/cjs/backend/FetchRequestBackend.d.ts +15 -15
  37. package/cjs/backend/FetchRequestBackend.js +203 -202
  38. package/cjs/backend/MockRequestBackend.d.ts +11 -11
  39. package/cjs/backend/MockRequestBackend.js +164 -164
  40. package/cjs/backend/RequestBackend.d.ts +19 -19
  41. package/cjs/backend/RequestBackend.js +2 -2
  42. package/cjs/cache/CacheBackend.d.ts +6 -6
  43. package/cjs/cache/CacheBackend.js +2 -2
  44. package/cjs/cache/Caching.d.ts +10 -10
  45. package/cjs/cache/Caching.js +88 -88
  46. package/cjs/cache/LocalForageCacheBackend.d.ts +9 -9
  47. package/cjs/cache/LocalForageCacheBackend.js +24 -24
  48. package/cjs/cache/LocalStorageCacheBackend.d.ts +7 -7
  49. package/cjs/cache/LocalStorageCacheBackend.js +77 -77
  50. package/cjs/index.d.ts +13 -13
  51. package/cjs/index.js +41 -41
  52. package/cjs/middleware/CacheMiddleware.d.ts +7 -7
  53. package/cjs/middleware/CacheMiddleware.js +107 -107
  54. package/cjs/middleware/LoggingMiddleware.d.ts +6 -6
  55. package/cjs/middleware/LoggingMiddleware.js +82 -88
  56. package/cjs/util/retry/index.d.ts +3 -3
  57. package/cjs/util/retry/index.js +52 -52
  58. package/cjs/util/retry/lib/retry.d.ts +3 -3
  59. package/cjs/util/retry/lib/retry.js +50 -54
  60. package/cjs/util/retry/lib/retryOperation.d.ts +27 -27
  61. package/cjs/util/retry/lib/retryOperation.js +130 -134
  62. package/esm/Api.d.ts +35 -35
  63. package/esm/Api.js +92 -98
  64. package/esm/ApiConstants.d.ts +58 -58
  65. package/esm/ApiConstants.js +52 -52
  66. package/esm/ApiTypes.d.ts +103 -103
  67. package/esm/ApiTypes.js +1 -1
  68. package/esm/ApiUtils.d.ts +6 -6
  69. package/esm/ApiUtils.js +43 -45
  70. package/esm/Endpoint.d.ts +52 -52
  71. package/esm/Endpoint.js +66 -70
  72. package/esm/EndpointBuilder.d.ts +14 -14
  73. package/esm/EndpointBuilder.js +31 -31
  74. package/esm/MockingTypes.d.ts +30 -30
  75. package/esm/MockingTypes.js +1 -1
  76. package/esm/QueryHandling.d.ts +3 -3
  77. package/esm/QueryHandling.js +19 -19
  78. package/esm/RequestConfig.d.ts +2 -2
  79. package/esm/RequestConfig.js +56 -56
  80. package/esm/RequestContext.d.ts +48 -48
  81. package/esm/RequestContext.js +167 -170
  82. package/esm/RequestError.d.ts +30 -30
  83. package/esm/RequestError.js +42 -42
  84. package/esm/Requester.d.ts +3 -3
  85. package/esm/Requester.js +252 -253
  86. package/esm/TextDecoding.d.ts +1 -1
  87. package/esm/TextDecoding.js +148 -135
  88. package/esm/UtilTypes.d.ts +5 -5
  89. package/esm/UtilTypes.js +1 -1
  90. package/esm/Utils.d.ts +15 -15
  91. package/esm/Utils.js +66 -68
  92. package/esm/Validation.d.ts +8 -8
  93. package/esm/Validation.js +1 -1
  94. package/esm/backend/AxiosRequestBackend.d.ts +13 -13
  95. package/esm/backend/AxiosRequestBackend.js +62 -62
  96. package/esm/backend/FetchRequestBackend.d.ts +15 -15
  97. package/esm/backend/FetchRequestBackend.js +136 -136
  98. package/esm/backend/MockRequestBackend.d.ts +11 -11
  99. package/esm/backend/MockRequestBackend.js +116 -116
  100. package/esm/backend/RequestBackend.d.ts +19 -19
  101. package/esm/backend/RequestBackend.js +1 -1
  102. package/esm/cache/CacheBackend.d.ts +6 -6
  103. package/esm/cache/CacheBackend.js +1 -1
  104. package/esm/cache/Caching.d.ts +10 -10
  105. package/esm/cache/Caching.js +39 -39
  106. package/esm/cache/LocalForageCacheBackend.d.ts +9 -9
  107. package/esm/cache/LocalForageCacheBackend.js +20 -20
  108. package/esm/cache/LocalStorageCacheBackend.d.ts +7 -7
  109. package/esm/cache/LocalStorageCacheBackend.js +32 -32
  110. package/esm/index.d.ts +13 -13
  111. package/esm/index.js +14 -15
  112. package/esm/middleware/CacheMiddleware.d.ts +7 -7
  113. package/esm/middleware/CacheMiddleware.js +58 -58
  114. package/esm/middleware/LoggingMiddleware.d.ts +6 -6
  115. package/esm/middleware/LoggingMiddleware.js +77 -83
  116. package/esm/util/retry/index.d.ts +3 -3
  117. package/esm/util/retry/index.js +50 -50
  118. package/esm/util/retry/lib/retry.d.ts +3 -3
  119. package/esm/util/retry/lib/retry.js +35 -39
  120. package/esm/util/retry/lib/retryOperation.d.ts +27 -27
  121. package/esm/util/retry/lib/retryOperation.js +126 -132
  122. package/package.json +19 -34
@@ -1,88 +1,82 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- var ApiUtils = require("../ApiUtils");
5
- var Utils = require("../Utils");
6
- var ApiConstants_1 = require("../ApiConstants");
7
- var LogType;
8
- (function (LogType) {
9
- LogType[LogType["Info"] = 0] = "Info";
10
- LogType[LogType["Success"] = 1] = "Success";
11
- LogType[LogType["Error"] = 2] = "Error";
12
- LogType[LogType["Warn"] = 3] = "Warn";
13
- })(LogType || (LogType = {}));
14
- var COLOR_MAP = (_a = {},
15
- _a[LogType.Error] = "#c8646c",
16
- _a[LogType.Info] = "#85a6c7",
17
- _a[LogType.Success] = "#a9c490",
18
- _a[LogType.Warn] = "#d19a66",
19
- _a);
20
- var diagnoseError = function (error) {
21
- if (!error.response) {
22
- if (ApiUtils.isNetworkError(error)) {
23
- return { message: "network issue", error: error };
24
- }
25
- if (ApiUtils.isCancelledError(error)) {
26
- return { message: "cancelled", error: error };
27
- }
28
- return { message: "client-side error", error: error };
29
- }
30
- var _a = error.response, status = _a.status, data = _a.data;
31
- var code = data === null || data === void 0 ? void 0 : data.code;
32
- return {
33
- message: "responded with ".concat(status).concat(code ? " (".concat(code, ")") : ""),
34
- response: error.response,
35
- };
36
- };
37
- var formatTime = function (time) {
38
- return "".concat(Utils.padNumber(time.getHours(), 2), ":").concat(Utils.padNumber(time.getMinutes(), 2), ":").concat(Utils.padNumber(time.getSeconds(), 2), ".").concat(Utils.padNumber(time.getMilliseconds(), 3));
39
- };
40
- var log = function (context, type, message, config, objects) {
41
- if (typeof config.predicate === "function" && !config.predicate()) {
42
- return;
43
- }
44
- var color = COLOR_MAP[type];
45
- var timestamp = formatTime(new Date());
46
- var args = [
47
- "%cnetwork %c[".concat(context.api.name, "] ").concat(context.method.toUpperCase(), " ").concat(context.path, " %c").concat(message, " %c@ ").concat(timestamp),
48
- "color:gray",
49
- "color:auto",
50
- "color:".concat(color),
51
- "color:gray",
52
- ];
53
- /* eslint-disable-next-line no-console */
54
- console.groupCollapsed.apply(console, args);
55
- /* eslint-disable-next-line no-console */
56
- console.log(Utils.assign({ context: context }, objects || {}));
57
- /* eslint-disable-next-line no-console */
58
- console.groupEnd();
59
- };
60
- var LoggingMiddleware = function (config) {
61
- var _a;
62
- if (config === void 0) { config = {}; }
63
- return _a = {},
64
- _a[ApiConstants_1.RequestEvent.BeforeSend] = function (context) {
65
- log(context, LogType.Info, context.stats.attempt > 1 ? "retrying" : "sending", config);
66
- },
67
- _a[ApiConstants_1.RequestEvent.Success] = function (context) {
68
- var _a;
69
- var cacheSource = context.cacheInfo.source;
70
- log(context, LogType.Success, "responded with ".concat((_a = context.response) === null || _a === void 0 ? void 0 : _a.status).concat(cacheSource ? " (cached by ".concat(cacheSource, ")") : ""), config);
71
- },
72
- _a[ApiConstants_1.RequestEvent.Error] = function (context) {
73
- if (context.error) {
74
- var _a = diagnoseError(context.error), error = _a.error, message = _a.message;
75
- log(context, LogType.Warn, "error on attempt ".concat(context.stats.attempt, " - ").concat(message), config, { error: error });
76
- }
77
- },
78
- _a[ApiConstants_1.RequestEvent.UnrecoverableError] = function (context) {
79
- if (context.error) {
80
- var _a = diagnoseError(context.error), error = _a.error, message = _a.message;
81
- log(context, LogType.Error, "failed - ".concat(message), config, {
82
- error: error,
83
- });
84
- }
85
- },
86
- _a;
87
- };
88
- exports.default = LoggingMiddleware;
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ var ApiConstants_1 = require("../ApiConstants");
5
+ var ApiUtils = require("../ApiUtils");
6
+ var Utils = require("../Utils");
7
+ var LogType;
8
+ (function (LogType) {
9
+ LogType[LogType["Info"] = 0] = "Info";
10
+ LogType[LogType["Success"] = 1] = "Success";
11
+ LogType[LogType["Error"] = 2] = "Error";
12
+ LogType[LogType["Warn"] = 3] = "Warn";
13
+ })(LogType || (LogType = {}));
14
+ var COLOR_MAP = (_a = {},
15
+ _a[LogType.Error] = "#c8646c",
16
+ _a[LogType.Info] = "#85a6c7",
17
+ _a[LogType.Success] = "#a9c490",
18
+ _a[LogType.Warn] = "#d19a66",
19
+ _a);
20
+ var diagnoseError = function (error) {
21
+ if (!error.response) {
22
+ if (ApiUtils.isNetworkError(error)) {
23
+ return { message: "network issue", error: error };
24
+ }
25
+ if (ApiUtils.isCancelledError(error)) {
26
+ return { message: "cancelled", error: error };
27
+ }
28
+ return { message: "client-side error", error: error };
29
+ }
30
+ var _a = error.response, status = _a.status, data = _a.data;
31
+ var code = data === null || data === void 0 ? void 0 : data.code;
32
+ return {
33
+ message: "responded with ".concat(status).concat(code ? " (".concat(code, ")") : ""),
34
+ response: error.response,
35
+ };
36
+ };
37
+ var formatTime = function (time) {
38
+ return "".concat(Utils.padNumber(time.getHours(), 2), ":").concat(Utils.padNumber(time.getMinutes(), 2), ":").concat(Utils.padNumber(time.getSeconds(), 2), ".").concat(Utils.padNumber(time.getMilliseconds(), 3));
39
+ };
40
+ var log = function (context, type, message, config, objects) {
41
+ if (typeof config.predicate === "function" && !config.predicate()) {
42
+ return;
43
+ }
44
+ var color = COLOR_MAP[type];
45
+ var timestamp = formatTime(new Date());
46
+ var args = ["%cnetwork %c[".concat(context.api.name, "] ").concat(context.method.toUpperCase(), " ").concat(context.path, " %c").concat(message, " %c@ ").concat(timestamp), "color:gray", "color:auto", "color:".concat(color), "color:gray"];
47
+ /* eslint-disable-next-line no-console */
48
+ console.groupCollapsed.apply(console, args);
49
+ /* eslint-disable-next-line no-console */
50
+ console.log(Utils.assign({ context: context }, objects || {}));
51
+ /* eslint-disable-next-line no-console */
52
+ console.groupEnd();
53
+ };
54
+ var LoggingMiddleware = function (config) {
55
+ var _a;
56
+ if (config === void 0) { config = {}; }
57
+ return _a = {},
58
+ _a[ApiConstants_1.RequestEvent.BeforeSend] = function (context) {
59
+ log(context, LogType.Info, context.stats.attempt > 1 ? "retrying" : "sending", config);
60
+ },
61
+ _a[ApiConstants_1.RequestEvent.Success] = function (context) {
62
+ var _a;
63
+ var cacheSource = context.cacheInfo.source;
64
+ log(context, LogType.Success, "responded with ".concat((_a = context.response) === null || _a === void 0 ? void 0 : _a.status).concat(cacheSource ? " (cached by ".concat(cacheSource, ")") : ""), config);
65
+ },
66
+ _a[ApiConstants_1.RequestEvent.Error] = function (context) {
67
+ if (context.error) {
68
+ var _a = diagnoseError(context.error), error = _a.error, message = _a.message;
69
+ log(context, LogType.Warn, "error on attempt ".concat(context.stats.attempt, " - ").concat(message), config, { error: error });
70
+ }
71
+ },
72
+ _a[ApiConstants_1.RequestEvent.UnrecoverableError] = function (context) {
73
+ if (context.error) {
74
+ var _a = diagnoseError(context.error), error = _a.error, message = _a.message;
75
+ log(context, LogType.Error, "failed - ".concat(message), config, {
76
+ error: error,
77
+ });
78
+ }
79
+ },
80
+ _a;
81
+ };
82
+ exports.default = LoggingMiddleware;
@@ -1,3 +1,3 @@
1
- import { RetryFunction, RetryOptions } from "./interfaces";
2
- declare const retry: <A>(fn: RetryFunction<A>, opts: RetryOptions) => Promise<A>;
3
- export default retry;
1
+ import { RetryFunction, RetryOptions } from "./interfaces";
2
+ declare const retry: <A>(fn: RetryFunction<A>, opts: RetryOptions) => Promise<A>;
3
+ export default retry;
@@ -1,52 +1,52 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var retrier = require("./lib/retry");
4
- // Retry is just transplanted from here:
5
- // https://www.npmjs.com/package/retry (lib), and
6
- // https://www.npmjs.com/package/async-retry (RetryFunction)
7
- // ---
8
- var retry = function (fn, opts) {
9
- return new Promise(function (resolve, reject) {
10
- var options = opts || {};
11
- if (!("randomize" in options)) {
12
- options.randomize = true;
13
- }
14
- var op = retrier.operation(options);
15
- // We allow the user to abort retrying
16
- // this makes sense in the cases where
17
- // knowledge is obtained that retrying
18
- // would be futile (e.g.: auth errors)
19
- var bail = function (err) {
20
- reject(err || new Error("Aborted"));
21
- };
22
- var onError = function (err, num) {
23
- if (err.bail) {
24
- bail(err);
25
- return;
26
- }
27
- if (!op.retry(err)) {
28
- reject(op.mainError());
29
- }
30
- else if (options.onRetry) {
31
- options.onRetry(err, num);
32
- }
33
- };
34
- var runAttempt = function (num) {
35
- var val;
36
- try {
37
- val = fn(bail, num);
38
- }
39
- catch (err) {
40
- onError(err, num);
41
- return;
42
- }
43
- Promise.resolve(val)
44
- .then(resolve)
45
- .catch(function catchIt(err) {
46
- onError(err, num);
47
- });
48
- };
49
- op.attempt(runAttempt);
50
- });
51
- };
52
- exports.default = retry;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var retrier = require("./lib/retry");
4
+ // Retry is just transplanted from here:
5
+ // https://www.npmjs.com/package/retry (lib), and
6
+ // https://www.npmjs.com/package/async-retry (RetryFunction)
7
+ // ---
8
+ var retry = function (fn, opts) {
9
+ return new Promise(function (resolve, reject) {
10
+ var options = opts || {};
11
+ if (!("randomize" in options)) {
12
+ options.randomize = true;
13
+ }
14
+ var op = retrier.operation(options);
15
+ // We allow the user to abort retrying
16
+ // this makes sense in the cases where
17
+ // knowledge is obtained that retrying
18
+ // would be futile (e.g.: auth errors)
19
+ var bail = function (err) {
20
+ reject(err || new Error("Aborted"));
21
+ };
22
+ var onError = function (err, num) {
23
+ if (err.bail) {
24
+ bail(err);
25
+ return;
26
+ }
27
+ if (!op.retry(err)) {
28
+ reject(op.mainError());
29
+ }
30
+ else if (options.onRetry) {
31
+ options.onRetry(err, num);
32
+ }
33
+ };
34
+ var runAttempt = function (num) {
35
+ var val;
36
+ try {
37
+ val = fn(bail, num);
38
+ }
39
+ catch (err) {
40
+ onError(err, num);
41
+ return;
42
+ }
43
+ Promise.resolve(val)
44
+ .then(resolve)
45
+ .catch(function catchIt(err) {
46
+ onError(err, num);
47
+ });
48
+ };
49
+ op.attempt(runAttempt);
50
+ });
51
+ };
52
+ exports.default = retry;
@@ -1,3 +1,3 @@
1
- import { RetryOptions } from "../interfaces";
2
- import RetryOperation from "./retryOperation";
3
- export declare const operation: (options: RetryOptions) => RetryOperation;
1
+ import { RetryOptions } from "../interfaces";
2
+ import RetryOperation from "./retryOperation";
3
+ export declare const operation: (options: RetryOptions) => RetryOperation;
@@ -1,54 +1,50 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.operation = void 0;
15
- var retryOperation_1 = require("./retryOperation");
16
- var operation = function (options) {
17
- var timeouts = _timeouts(options);
18
- return (new retryOperation_1.default(timeouts, {
19
- forever: options && (options.forever || options.retries === Infinity),
20
- unref: options && options.unref,
21
- maxRetryTime: options && options.maxRetryTime,
22
- }));
23
- };
24
- exports.operation = operation;
25
- var _timeouts = function (options) {
26
- var _a;
27
- var createTimeout = function (attempt, opts) {
28
- var random = (opts.randomize)
29
- ? (Math.random() + 1)
30
- : 1;
31
- var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
32
- timeout = Math.min(timeout, opts.maxTimeout);
33
- return (timeout);
34
- };
35
- var defaultRetries = 10;
36
- var opts = __assign({ retries: defaultRetries, factor: 2, minTimeout: 1 * 1000, maxTimeout: Infinity, randomize: false }, options);
37
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
38
- if (opts.minTimeout > opts.maxTimeout) {
39
- throw new Error("minTimeout is greater than maxTimeout");
40
- }
41
- var timeouts = [];
42
- var numRetries = (_a = opts.retries) !== null && _a !== void 0 ? _a : defaultRetries;
43
- for (var i = 0; i < numRetries; i++) {
44
- timeouts.push(createTimeout(i, opts));
45
- }
46
- if (options && options.forever && !timeouts.length) {
47
- timeouts.push(createTimeout(numRetries, opts));
48
- }
49
- // sort the array numerically ascending
50
- timeouts.sort(function (a, b) {
51
- return a - b;
52
- });
53
- return (timeouts);
54
- };
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.operation = void 0;
15
+ var retryOperation_1 = require("./retryOperation");
16
+ var operation = function (options) {
17
+ var timeouts = _timeouts(options);
18
+ return new retryOperation_1.default(timeouts, {
19
+ forever: options && (options.forever || options.retries === Infinity),
20
+ unref: options === null || options === void 0 ? void 0 : options.unref,
21
+ maxRetryTime: options === null || options === void 0 ? void 0 : options.maxRetryTime,
22
+ });
23
+ };
24
+ exports.operation = operation;
25
+ var _timeouts = function (options) {
26
+ var _a;
27
+ var createTimeout = function (attempt, opts) {
28
+ var random = opts.randomize ? Math.random() + 1 : 1;
29
+ var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
30
+ timeout = Math.min(timeout, opts.maxTimeout);
31
+ return timeout;
32
+ };
33
+ var defaultRetries = 10;
34
+ var opts = __assign({ retries: defaultRetries, factor: 2, minTimeout: 1 * 1000, maxTimeout: Infinity, randomize: false }, options);
35
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
36
+ if (opts.minTimeout > opts.maxTimeout) {
37
+ throw new Error("minTimeout is greater than maxTimeout");
38
+ }
39
+ var timeouts = [];
40
+ var numRetries = (_a = opts.retries) !== null && _a !== void 0 ? _a : defaultRetries;
41
+ for (var i = 0; i < numRetries; i++) {
42
+ timeouts.push(createTimeout(i, opts));
43
+ }
44
+ if ((options === null || options === void 0 ? void 0 : options.forever) && !timeouts.length) {
45
+ timeouts.push(createTimeout(numRetries, opts));
46
+ }
47
+ // sort the array numerically ascending
48
+ timeouts.sort(function (a, b) { return a - b; });
49
+ return timeouts;
50
+ };
@@ -1,27 +1,27 @@
1
- export default RetryOperation;
2
- declare function RetryOperation(timeouts: any, options: any): void;
3
- declare class RetryOperation {
4
- constructor(timeouts: any, options: any);
5
- _originalTimeouts: any;
6
- _timeouts: any;
7
- _options: any;
8
- _maxRetryTime: any;
9
- _fn: any;
10
- _errors: any[];
11
- _attempts: number;
12
- _operationTimeout: any;
13
- _operationTimeoutCb: any;
14
- _timeout: NodeJS.Timeout | null;
15
- _operationStart: number | null;
16
- _timer: NodeJS.Timeout | null;
17
- _cachedTimeouts: any;
18
- reset(): void;
19
- stop(): void;
20
- retry(err: any): boolean;
21
- attempt(fn: any, timeoutOps: any): void;
22
- try(fn: any): void;
23
- start: (fn: any) => void;
24
- errors(): any[];
25
- attempts(): number;
26
- mainError(): any;
27
- }
1
+ export default RetryOperation;
2
+ declare function RetryOperation(timeouts: any, options: any): void;
3
+ declare class RetryOperation {
4
+ constructor(timeouts: any, options: any);
5
+ _originalTimeouts: any;
6
+ _timeouts: any;
7
+ _options: any;
8
+ _maxRetryTime: any;
9
+ _fn: any;
10
+ _errors: any[];
11
+ _attempts: number;
12
+ _operationTimeout: any;
13
+ _operationTimeoutCb: any;
14
+ _timeout: NodeJS.Timeout | null;
15
+ _operationStart: number | null;
16
+ _timer: NodeJS.Timeout | null;
17
+ _cachedTimeouts: any;
18
+ reset(): void;
19
+ stop(): void;
20
+ retry(err: any): boolean;
21
+ attempt(fn: any, timeoutOps: any): void;
22
+ try(fn: any): void;
23
+ start: (fn: any) => void;
24
+ errors(): any[];
25
+ attempts(): number;
26
+ mainError(): any;
27
+ }