backoff-rxjs
Advanced tools
Comparing version 6.1.1 to 6.1.2
@@ -1,2 +0,2 @@ | ||
import { Observable, SchedulerLike } from "rxjs"; | ||
import { Observable, SchedulerLike } from 'rxjs'; | ||
export interface IntervalBackoffConfig { | ||
@@ -3,0 +3,0 @@ initialInterval: number; |
@@ -12,3 +12,3 @@ "use strict"; | ||
if (scheduler === void 0) { scheduler = rxjs_1.asyncScheduler; } | ||
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; | ||
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; | ||
@@ -15,0 +15,0 @@ return rxjs_1.of(0, scheduler).pipe( |
import { Observable } from 'rxjs'; | ||
export interface RetryBackoffConfig { | ||
initialInterval: number; | ||
maxAttempts?: number; | ||
maxRetries?: number; | ||
maxInterval?: number; | ||
@@ -6,0 +6,0 @@ shouldRetry?: (error: any) => boolean; |
@@ -15,5 +15,11 @@ "use strict"; | ||
function retryBackoff(config) { | ||
var _a = (typeof config === 'number') ? { initialInterval: config } : config, initialInterval = _a.initialInterval, _b = _a.maxAttempts, maxAttempts = _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; | ||
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 < maxAttempts && shouldRetry(error); }, rxjs_1.timer(utils_1.getDelay(backoffDelay(i, initialInterval), maxInterval)), rxjs_1.throwError(error)); })); })); }; | ||
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; | ||
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)); | ||
})); | ||
})); | ||
}; | ||
} | ||
exports.retryBackoff = retryBackoff; |
{ | ||
"name": "backoff-rxjs", | ||
"version": "6.1.1", | ||
"version": "6.1.2", | ||
"description": "A collection of helpful RxJS operators to deal with backoff strategies (like exponential backoff)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
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
57601
601