backoff-rxjs
Advanced tools
Comparing version 6.3.3 to 6.5.5
@@ -1,1 +0,1 @@ | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define(["rxjs","rxjs/operators"],r):"object"==typeof exports?exports["backoff-rxjs"]=r(require("rxjs"),require("rxjs/operators")):e["backoff-rxjs"]=r(e.rxjs,e.rxjs.operators)}(window,(function(e,r){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=3)}([function(r,t){r.exports=e},function(e,t){e.exports=r},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getDelay=function(e,r){return Math.min(e,r)},r.exponentialBackoffDelay=function(e,r){return Math.pow(2,e)*r}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(4);r.retryBackoff=n.retryBackoff;var o=t(5);r.intervalBackoff=o.intervalBackoff},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(0),o=t(1),i=t(2);r.retryBackoff=function(e){var r="number"==typeof e?{initialInterval:e}:e,t=r.initialInterval,u=r.maxRetries,f=void 0===u?1/0:u,a=r.maxInterval,c=void 0===a?1/0:a,l=r.shouldRetry,p=void 0===l?function(){return!0}:l,s=r.backoffDelay,d=void 0===s?i.exponentialBackoffDelay:s;return function(e){return e.pipe(o.retryWhen((function(e){return e.pipe(o.concatMap((function(e,r){return n.iif((function(){return r<f&&p(e)}),n.timer(i.getDelay(d(r,t),c)),n.throwError(e))})))})))}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(0),o=t(1),i=t(2);r.intervalBackoff=function(e,r){void 0===r&&(r=n.asyncScheduler);var t="number"==typeof e?{initialInterval:e}:e,u=t.initialInterval,f=t.maxInterval,a=void 0===f?1/0:f,c=t.backoffDelay,l=void 0===c?i.exponentialBackoffDelay:c;return u=u<0?0:u,n.of(0,r).pipe(o.expand((function(e){return n.timer(i.getDelay(l(e,u),a)).pipe(o.mapTo(e+1))})))}}])})); | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define(["rxjs","rxjs/operators"],r):"object"==typeof exports?exports["backoff-rxjs"]=r(require("rxjs"),require("rxjs/operators")):e["backoff-rxjs"]=r(e.rxjs,e.rxjs.operators)}(window,(function(e,r){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=3)}([function(r,t){r.exports=e},function(e,t){e.exports=r},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.exponentialBackoffDelay=r.getDelay=void 0,r.getDelay=function(e,r){return Math.min(e,r)},r.exponentialBackoffDelay=function(e,r){return Math.pow(2,e)*r}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(4);Object.defineProperty(r,"retryBackoff",{enumerable:!0,get:function(){return n.retryBackoff}});var o=t(5);Object.defineProperty(r,"intervalBackoff",{enumerable:!0,get:function(){return o.intervalBackoff}})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.retryBackoff=void 0;var n=t(0),o=t(1),i=t(2);r.retryBackoff=function(e){var r="number"==typeof e?{initialInterval:e}:e,t=r.initialInterval,f=r.maxRetries,u=void 0===f?1/0:f,a=r.maxInterval,c=void 0===a?1/0:a,l=r.shouldRetry,p=void 0===l?function(){return!0}:l,s=r.resetOnSuccess,d=void 0!==s&&s,v=r.backoffDelay,y=void 0===v?i.exponentialBackoffDelay:v;return function(e){return n.defer((function(){var r=0;return e.pipe(o.retryWhen((function(e){return e.pipe(o.concatMap((function(e){var o=r++;return n.iif((function(){return o<u&&p(e)}),n.timer(i.getDelay(y(o,t),c)),n.throwError(e))})))})),o.tap((function(){d&&(r=0)})))}))}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.intervalBackoff=void 0;var n=t(0),o=t(1),i=t(2);r.intervalBackoff=function(e,r){void 0===r&&(r=n.asyncScheduler);var t="number"==typeof e?{initialInterval:e}:e,f=t.initialInterval,u=t.maxInterval,a=void 0===u?1/0:u,c=t.backoffDelay,l=void 0===c?i.exponentialBackoffDelay:c;return f=f<0?0:f,n.of(0,r).pipe(o.expand((function(e){return n.timer(i.getDelay(l(e,f),a)).pipe(o.mapTo(e+1))})))}}])})); |
@@ -107,3 +107,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
"use strict"; | ||
eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar retryBackoff_1 = __webpack_require__(/*! ./operators/retryBackoff */ \"./src/operators/retryBackoff.ts\");\nexports.retryBackoff = retryBackoff_1.retryBackoff;\nvar intervalBackoff_1 = __webpack_require__(/*! ./observable/intervalBackoff */ \"./src/observable/intervalBackoff.ts\");\nexports.intervalBackoff = intervalBackoff_1.intervalBackoff;\n\n\n//# sourceURL=webpack://backoff-rxjs/./src/index.ts?"); | ||
eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar retryBackoff_1 = __webpack_require__(/*! ./operators/retryBackoff */ \"./src/operators/retryBackoff.ts\");\nObject.defineProperty(exports, \"retryBackoff\", { enumerable: true, get: function () { return retryBackoff_1.retryBackoff; } });\nvar intervalBackoff_1 = __webpack_require__(/*! ./observable/intervalBackoff */ \"./src/observable/intervalBackoff.ts\");\nObject.defineProperty(exports, \"intervalBackoff\", { enumerable: true, get: function () { return intervalBackoff_1.intervalBackoff; } });\n\n\n//# sourceURL=webpack://backoff-rxjs/./src/index.ts?"); | ||
@@ -120,3 +120,3 @@ /***/ }), | ||
"use strict"; | ||
eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar rxjs_1 = __webpack_require__(/*! rxjs */ \"rxjs\");\nvar operators_1 = __webpack_require__(/*! rxjs/operators */ \"rxjs/operators\");\nvar utils_1 = __webpack_require__(/*! ../utils */ \"./src/utils.ts\");\nfunction intervalBackoff(config, scheduler) {\n if (scheduler === void 0) { scheduler = rxjs_1.asyncScheduler; }\n var _a = typeof config === 'number' ? { initialInterval: config } : config, initialInterval = _a.initialInterval, _b = _a.maxInterval, maxInterval = _b === void 0 ? Infinity : _b, _c = _a.backoffDelay, backoffDelay = _c === void 0 ? utils_1.exponentialBackoffDelay : _c;\n initialInterval = (initialInterval < 0) ? 0 : initialInterval;\n return rxjs_1.of(0, scheduler).pipe(operators_1.expand(function (iteration) {\n return rxjs_1.timer(utils_1.getDelay(backoffDelay(iteration, initialInterval), maxInterval))\n .pipe(operators_1.mapTo(iteration + 1));\n }));\n}\nexports.intervalBackoff = intervalBackoff;\n\n\n//# sourceURL=webpack://backoff-rxjs/./src/observable/intervalBackoff.ts?"); | ||
eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.intervalBackoff = void 0;\nvar rxjs_1 = __webpack_require__(/*! rxjs */ \"rxjs\");\nvar operators_1 = __webpack_require__(/*! rxjs/operators */ \"rxjs/operators\");\nvar utils_1 = __webpack_require__(/*! ../utils */ \"./src/utils.ts\");\nfunction intervalBackoff(config, scheduler) {\n if (scheduler === void 0) { scheduler = rxjs_1.asyncScheduler; }\n var _a = typeof config === 'number' ? { initialInterval: config } : config, initialInterval = _a.initialInterval, _b = _a.maxInterval, maxInterval = _b === void 0 ? Infinity : _b, _c = _a.backoffDelay, backoffDelay = _c === void 0 ? utils_1.exponentialBackoffDelay : _c;\n initialInterval = initialInterval < 0 ? 0 : initialInterval;\n return rxjs_1.of(0, scheduler).pipe(operators_1.expand(function (iteration) {\n return rxjs_1.timer(utils_1.getDelay(backoffDelay(iteration, initialInterval), maxInterval))\n .pipe(operators_1.mapTo(iteration + 1));\n }));\n}\nexports.intervalBackoff = intervalBackoff;\n\n\n//# sourceURL=webpack://backoff-rxjs/./src/observable/intervalBackoff.ts?"); | ||
@@ -133,3 +133,3 @@ /***/ }), | ||
"use strict"; | ||
eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar rxjs_1 = __webpack_require__(/*! rxjs */ \"rxjs\");\nvar operators_1 = __webpack_require__(/*! rxjs/operators */ \"rxjs/operators\");\nvar utils_1 = __webpack_require__(/*! ../utils */ \"./src/utils.ts\");\nfunction retryBackoff(config) {\n var _a = typeof config === 'number' ? { initialInterval: config } : config, initialInterval = _a.initialInterval, _b = _a.maxRetries, maxRetries = _b === void 0 ? Infinity : _b, _c = _a.maxInterval, maxInterval = _c === void 0 ? Infinity : _c, _d = _a.shouldRetry, shouldRetry = _d === void 0 ? function () { return true; } : _d, _e = _a.backoffDelay, backoffDelay = _e === void 0 ? utils_1.exponentialBackoffDelay : _e;\n return function (source) {\n return source.pipe(operators_1.retryWhen(function (errors) {\n return errors.pipe(operators_1.concatMap(function (error, i) {\n return rxjs_1.iif(function () { return i < maxRetries && shouldRetry(error); }, rxjs_1.timer(utils_1.getDelay(backoffDelay(i, initialInterval), maxInterval)), rxjs_1.throwError(error));\n }));\n }));\n };\n}\nexports.retryBackoff = retryBackoff;\n\n\n//# sourceURL=webpack://backoff-rxjs/./src/operators/retryBackoff.ts?"); | ||
eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.retryBackoff = void 0;\nvar rxjs_1 = __webpack_require__(/*! rxjs */ \"rxjs\");\nvar operators_1 = __webpack_require__(/*! rxjs/operators */ \"rxjs/operators\");\nvar utils_1 = __webpack_require__(/*! ../utils */ \"./src/utils.ts\");\nfunction retryBackoff(config) {\n var _a = typeof config === 'number' ? { initialInterval: config } : config, initialInterval = _a.initialInterval, _b = _a.maxRetries, maxRetries = _b === void 0 ? Infinity : _b, _c = _a.maxInterval, maxInterval = _c === void 0 ? Infinity : _c, _d = _a.shouldRetry, shouldRetry = _d === void 0 ? function () { return true; } : _d, _e = _a.resetOnSuccess, resetOnSuccess = _e === void 0 ? false : _e, _f = _a.backoffDelay, backoffDelay = _f === void 0 ? utils_1.exponentialBackoffDelay : _f;\n return function (source) {\n return rxjs_1.defer(function () {\n var index = 0;\n return source.pipe(operators_1.retryWhen(function (errors) {\n return errors.pipe(operators_1.concatMap(function (error) {\n var attempt = index++;\n return rxjs_1.iif(function () { return attempt < maxRetries && shouldRetry(error); }, rxjs_1.timer(utils_1.getDelay(backoffDelay(attempt, initialInterval), maxInterval)), rxjs_1.throwError(error));\n }));\n }), operators_1.tap(function () {\n if (resetOnSuccess) {\n index = 0;\n }\n }));\n });\n };\n}\nexports.retryBackoff = retryBackoff;\n\n\n//# sourceURL=webpack://backoff-rxjs/./src/operators/retryBackoff.ts?"); | ||
@@ -146,3 +146,3 @@ /***/ }), | ||
"use strict"; | ||
eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction getDelay(backoffDelay, maxInterval) {\n return Math.min(backoffDelay, maxInterval);\n}\nexports.getDelay = getDelay;\nfunction exponentialBackoffDelay(iteration, initialInterval) {\n return Math.pow(2, iteration) * initialInterval;\n}\nexports.exponentialBackoffDelay = exponentialBackoffDelay;\n\n\n//# sourceURL=webpack://backoff-rxjs/./src/utils.ts?"); | ||
eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.exponentialBackoffDelay = exports.getDelay = void 0;\nfunction getDelay(backoffDelay, maxInterval) {\n return Math.min(backoffDelay, maxInterval);\n}\nexports.getDelay = getDelay;\nfunction exponentialBackoffDelay(iteration, initialInterval) {\n return Math.pow(2, iteration) * initialInterval;\n}\nexports.exponentialBackoffDelay = exponentialBackoffDelay;\n\n\n//# sourceURL=webpack://backoff-rxjs/./src/utils.ts?"); | ||
@@ -149,0 +149,0 @@ /***/ }), |
export { retryBackoff } from './operators/retryBackoff'; | ||
export { intervalBackoff } from './observable/intervalBackoff'; | ||
export { intervalBackoff, } from './observable/intervalBackoff'; |
@@ -5,6 +5,6 @@ import { of, timer, asyncScheduler } from 'rxjs'; | ||
export function intervalBackoff(config, scheduler = asyncScheduler) { | ||
let { initialInterval, maxInterval = Infinity, backoffDelay = exponentialBackoffDelay } = typeof config === 'number' ? { initialInterval: config } : config; | ||
initialInterval = (initialInterval < 0) ? 0 : initialInterval; | ||
let { initialInterval, maxInterval = Infinity, backoffDelay = exponentialBackoffDelay, } = typeof config === 'number' ? { initialInterval: config } : config; | ||
initialInterval = initialInterval < 0 ? 0 : initialInterval; | ||
return of(0, scheduler).pipe(expand(iteration => timer(getDelay(backoffDelay(iteration, initialInterval), maxInterval)) | ||
.pipe(mapTo(iteration + 1)))); | ||
} |
@@ -1,7 +0,17 @@ | ||
import { iif, throwError, timer } from 'rxjs'; | ||
import { concatMap, retryWhen } from 'rxjs/operators'; | ||
import { getDelay, exponentialBackoffDelay } from '../utils'; | ||
import { defer, iif, throwError, timer } from 'rxjs'; | ||
import { concatMap, retryWhen, tap } from 'rxjs/operators'; | ||
import { exponentialBackoffDelay, getDelay } from '../utils'; | ||
export function retryBackoff(config) { | ||
const { initialInterval, maxRetries = Infinity, maxInterval = Infinity, shouldRetry = () => true, backoffDelay = exponentialBackoffDelay } = typeof config === 'number' ? { initialInterval: config } : config; | ||
return (source) => source.pipe(retryWhen(errors => errors.pipe(concatMap((error, i) => iif(() => i < maxRetries && shouldRetry(error), timer(getDelay(backoffDelay(i, initialInterval), maxInterval)), throwError(error)))))); | ||
const { initialInterval, maxRetries = Infinity, maxInterval = Infinity, shouldRetry = () => true, resetOnSuccess = false, backoffDelay = exponentialBackoffDelay, } = typeof config === 'number' ? { initialInterval: config } : config; | ||
return (source) => defer(() => { | ||
let index = 0; | ||
return source.pipe(retryWhen(errors => errors.pipe(concatMap(error => { | ||
const attempt = index++; | ||
return iif(() => attempt < maxRetries && shouldRetry(error), timer(getDelay(backoffDelay(attempt, initialInterval), maxInterval)), throwError(error)); | ||
}))), tap(() => { | ||
if (resetOnSuccess) { | ||
index = 0; | ||
} | ||
})); | ||
}); | ||
} |
export { retryBackoff } from './operators/retryBackoff'; | ||
export { intervalBackoff } from './observable/intervalBackoff'; | ||
export { intervalBackoff, } from './observable/intervalBackoff'; |
@@ -7,3 +7,3 @@ import { of, timer, asyncScheduler } from 'rxjs'; | ||
var _a = typeof config === 'number' ? { initialInterval: config } : config, initialInterval = _a.initialInterval, _b = _a.maxInterval, maxInterval = _b === void 0 ? Infinity : _b, _c = _a.backoffDelay, backoffDelay = _c === void 0 ? exponentialBackoffDelay : _c; | ||
initialInterval = (initialInterval < 0) ? 0 : initialInterval; | ||
initialInterval = initialInterval < 0 ? 0 : initialInterval; | ||
return of(0, scheduler).pipe(expand(function (iteration) { | ||
@@ -10,0 +10,0 @@ return timer(getDelay(backoffDelay(iteration, initialInterval), maxInterval)) |
@@ -1,13 +0,21 @@ | ||
import { iif, throwError, timer } from 'rxjs'; | ||
import { concatMap, retryWhen } from 'rxjs/operators'; | ||
import { getDelay, exponentialBackoffDelay } from '../utils'; | ||
import { defer, iif, throwError, timer } from 'rxjs'; | ||
import { concatMap, retryWhen, tap } from 'rxjs/operators'; | ||
import { exponentialBackoffDelay, getDelay } from '../utils'; | ||
export function retryBackoff(config) { | ||
var _a = typeof config === 'number' ? { initialInterval: config } : config, initialInterval = _a.initialInterval, _b = _a.maxRetries, maxRetries = _b === void 0 ? Infinity : _b, _c = _a.maxInterval, maxInterval = _c === void 0 ? Infinity : _c, _d = _a.shouldRetry, shouldRetry = _d === void 0 ? function () { return true; } : _d, _e = _a.backoffDelay, backoffDelay = _e === void 0 ? exponentialBackoffDelay : _e; | ||
var _a = typeof config === 'number' ? { initialInterval: config } : config, initialInterval = _a.initialInterval, _b = _a.maxRetries, maxRetries = _b === void 0 ? Infinity : _b, _c = _a.maxInterval, maxInterval = _c === void 0 ? Infinity : _c, _d = _a.shouldRetry, shouldRetry = _d === void 0 ? function () { return true; } : _d, _e = _a.resetOnSuccess, resetOnSuccess = _e === void 0 ? false : _e, _f = _a.backoffDelay, backoffDelay = _f === void 0 ? exponentialBackoffDelay : _f; | ||
return function (source) { | ||
return source.pipe(retryWhen(function (errors) { | ||
return errors.pipe(concatMap(function (error, i) { | ||
return iif(function () { return i < maxRetries && shouldRetry(error); }, timer(getDelay(backoffDelay(i, initialInterval), maxInterval)), throwError(error)); | ||
return defer(function () { | ||
var index = 0; | ||
return source.pipe(retryWhen(function (errors) { | ||
return errors.pipe(concatMap(function (error) { | ||
var attempt = index++; | ||
return iif(function () { return attempt < maxRetries && shouldRetry(error); }, timer(getDelay(backoffDelay(attempt, initialInterval), maxInterval)), throwError(error)); | ||
})); | ||
}), tap(function () { | ||
if (resetOnSuccess) { | ||
index = 0; | ||
} | ||
})); | ||
})); | ||
}); | ||
}; | ||
} |
export { retryBackoff, RetryBackoffConfig } from './operators/retryBackoff'; | ||
export { intervalBackoff, IntervalBackoffConfig } from './observable/intervalBackoff'; | ||
export { intervalBackoff, IntervalBackoffConfig, } from './observable/intervalBackoff'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var retryBackoff_1 = require("./operators/retryBackoff"); | ||
exports.retryBackoff = retryBackoff_1.retryBackoff; | ||
Object.defineProperty(exports, "retryBackoff", { enumerable: true, get: function () { return retryBackoff_1.retryBackoff; } }); | ||
var intervalBackoff_1 = require("./observable/intervalBackoff"); | ||
exports.intervalBackoff = intervalBackoff_1.intervalBackoff; | ||
Object.defineProperty(exports, "intervalBackoff", { enumerable: true, get: function () { return intervalBackoff_1.intervalBackoff; } }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.intervalBackoff = void 0; | ||
var rxjs_1 = require("rxjs"); | ||
@@ -9,3 +10,3 @@ var operators_1 = require("rxjs/operators"); | ||
var _a = typeof config === 'number' ? { initialInterval: config } : config, initialInterval = _a.initialInterval, _b = _a.maxInterval, maxInterval = _b === void 0 ? Infinity : _b, _c = _a.backoffDelay, backoffDelay = _c === void 0 ? utils_1.exponentialBackoffDelay : _c; | ||
initialInterval = (initialInterval < 0) ? 0 : initialInterval; | ||
initialInterval = initialInterval < 0 ? 0 : initialInterval; | ||
return rxjs_1.of(0, scheduler).pipe(operators_1.expand(function (iteration) { | ||
@@ -12,0 +13,0 @@ return rxjs_1.timer(utils_1.getDelay(backoffDelay(iteration, initialInterval), maxInterval)) |
@@ -6,2 +6,3 @@ import { Observable } from 'rxjs'; | ||
maxInterval?: number; | ||
resetOnSuccess?: boolean; | ||
shouldRetry?: (error: any) => boolean; | ||
@@ -8,0 +9,0 @@ backoffDelay?: (iteration: number, initialInterval: number) => number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.retryBackoff = void 0; | ||
var rxjs_1 = require("rxjs"); | ||
@@ -7,11 +8,19 @@ var operators_1 = require("rxjs/operators"); | ||
function retryBackoff(config) { | ||
var _a = typeof config === 'number' ? { initialInterval: config } : config, initialInterval = _a.initialInterval, _b = _a.maxRetries, maxRetries = _b === void 0 ? Infinity : _b, _c = _a.maxInterval, maxInterval = _c === void 0 ? Infinity : _c, _d = _a.shouldRetry, shouldRetry = _d === void 0 ? function () { return true; } : _d, _e = _a.backoffDelay, backoffDelay = _e === void 0 ? utils_1.exponentialBackoffDelay : _e; | ||
var _a = typeof config === 'number' ? { initialInterval: config } : config, initialInterval = _a.initialInterval, _b = _a.maxRetries, maxRetries = _b === void 0 ? Infinity : _b, _c = _a.maxInterval, maxInterval = _c === void 0 ? Infinity : _c, _d = _a.shouldRetry, shouldRetry = _d === void 0 ? function () { return true; } : _d, _e = _a.resetOnSuccess, resetOnSuccess = _e === void 0 ? false : _e, _f = _a.backoffDelay, backoffDelay = _f === void 0 ? utils_1.exponentialBackoffDelay : _f; | ||
return function (source) { | ||
return source.pipe(operators_1.retryWhen(function (errors) { | ||
return errors.pipe(operators_1.concatMap(function (error, i) { | ||
return rxjs_1.iif(function () { return i < maxRetries && shouldRetry(error); }, rxjs_1.timer(utils_1.getDelay(backoffDelay(i, initialInterval), maxInterval)), rxjs_1.throwError(error)); | ||
return rxjs_1.defer(function () { | ||
var index = 0; | ||
return source.pipe(operators_1.retryWhen(function (errors) { | ||
return errors.pipe(operators_1.concatMap(function (error) { | ||
var attempt = index++; | ||
return rxjs_1.iif(function () { return attempt < maxRetries && shouldRetry(error); }, rxjs_1.timer(utils_1.getDelay(backoffDelay(attempt, initialInterval), maxInterval)), rxjs_1.throwError(error)); | ||
})); | ||
}), operators_1.tap(function () { | ||
if (resetOnSuccess) { | ||
index = 0; | ||
} | ||
})); | ||
})); | ||
}); | ||
}; | ||
} | ||
exports.retryBackoff = retryBackoff; |
{ | ||
"name": "backoff-rxjs", | ||
"version": "6.3.3", | ||
"version": "6.5.5", | ||
"description": "A collection of helpful RxJS operators to deal with backoff strategies (like exponential backoff)", | ||
@@ -20,3 +20,3 @@ "main": "./index.js", | ||
"author": "Alex Okrushko", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"bugs": { | ||
@@ -30,4 +30,7 @@ "url": "https://github.com/alex-okrushko/backoff-rxjs/issues" | ||
"devDependencies": {}, | ||
"dependencies": { | ||
"rxjs": "^6.5.5" | ||
}, | ||
"private": false, | ||
"unpkg": "./bundles/backoff-rxjs.min.umd.js" | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.exponentialBackoffDelay = exports.getDelay = void 0; | ||
function getDelay(backoffDelay, maxInterval) { | ||
@@ -4,0 +5,0 @@ return Math.min(backoffDelay, maxInterval); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
28229
0
318
2
1
+ Addedrxjs@^6.5.5