backoff-rxjs
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,2 +0,2 @@ | ||
export { retryBackoffExponential, RetryBackoffExponentialConfig } from './operators/retryBackoffExponential'; | ||
export { intervalBackoffExponential, IntervalBackoffExponentialConfig } from './observable/intervalBackoffExponential'; | ||
export { retryBackoff, RetryBackoffConfig } from './operators/retryBackoff'; | ||
export { intervalBackoff, IntervalBackoffConfig } from './observable/intervalBackoff'; |
@@ -1,2 +0,2 @@ | ||
export { retryBackoffExponential } from './operators/retryBackoffExponential'; | ||
export { intervalBackoffExponential } from './observable/intervalBackoffExponential'; | ||
export { retryBackoff } from './operators/retryBackoff'; | ||
export { intervalBackoff } from './observable/intervalBackoff'; |
@@ -1,1 +0,4 @@ | ||
export declare function getDelay(iteration: number, initialInterval: number, maxInterval: number): number; | ||
/** Calculates the actual delay which can be limited by maxInterval */ | ||
export declare function getDelay(backoffDelay: number, maxInterval: number): number; | ||
/** Exponential backoff delay */ | ||
export declare function exponentialBackoffDelay(iteration: number, initialInterval: number): number; |
@@ -1,4 +0,8 @@ | ||
export function getDelay(iteration, initialInterval, maxInterval) { | ||
var currentDelay = Math.pow(2, iteration) * initialInterval; | ||
return Math.min(currentDelay, maxInterval); | ||
/** Calculates the actual delay which can be limited by maxInterval */ | ||
export function getDelay(backoffDelay, maxInterval) { | ||
return Math.min(backoffDelay, maxInterval); | ||
} | ||
/** Exponential backoff delay */ | ||
export function exponentialBackoffDelay(iteration, initialInterval) { | ||
return Math.pow(2, iteration) * initialInterval; | ||
} |
{ | ||
"name": "backoff-rxjs", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A collection of helpful RxJS operators to deal with backoff strategies (like exponential backoff)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# backoff-rxjs | ||
A collection of helpful RxJS operators to deal with backoff strategies (like exponential backoff) | ||
## intervalExponential | ||
![Basic interval Exponential](./intervalExponentialBasic.svg) | ||
## intervalBackoff | ||
![Basic interval backoff](./intervalBackoffBasic.svg) | ||
`intervalExponential` works similiarly to `interval` except that it doubles the delay between emissions every time. | ||
`intervalBackoff` works similiarly to `interval` except that it doubles the delay between emissions every time. | ||
| name | type | attirbute | description | | ||
| ------------- |-------------| -----| ---------------| | ||
| config | [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [IntervalExponentialConfig](https://github.com/alex-okrushko/backoff-rxjs/blob/277fbbbde4b046733070e2ed64e0b765699fb66b/src/observable/intervalExponential.ts#L6)| required |Can take number as initial interval or a config with initial interval and optional max Interval | | ||
| config | [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [IntervalBackoffConfig](https://github.com/alex-okrushko/backoff-rxjs/blob/bddb11d6d06d2d2ccdeb12e3c779bc3ae03311db/src/observable/intervalBackoff.ts#L6)| required |Can take number as initial interval or a config with initial interval, optional max Interval and optional backoff delay function (exponential by default) | | ||
`intervalExponential` is especially useful for periodic polls that are reset whenever user activity is detected: | ||
`interval` is especially useful for periodic polls that are reset whenever user activity is detected: | ||
```ts | ||
@@ -26,3 +25,3 @@ fromEvent(document, 'mousemove').pipe( | ||
// Resetting exponential interval | ||
switchMapTo(intervalExponential({initialInterval: LOAD_INTERVAL_MS, maxInterval: MAX_INTERVAL_MS})), | ||
switchMapTo(intervalBackoff({initialInterval: LOAD_INTERVAL_MS, maxInterval: MAX_INTERVAL_MS})), | ||
); | ||
@@ -32,7 +31,7 @@ ``` | ||
## retryExponentialBackoff | ||
![Retry Backoff Exponential Image](./retryBackoffExponential.svg) | ||
## retryBackoff | ||
![Retry Backoff Exponential Image](./retryBackoff.svg) | ||
| name | type | attirbute | description | | ||
| ------------- |-------------| -----| ---------------| | ||
| config | [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [IntervalExponentialConfig](https://github.com/alex-okrushko/backoff-rxjs/blob/277fbbbde4b046733070e2ed64e0b765699fb66b/src/observable/intervalExponential.ts#L6)| required |Can take number as initial interval or a config with initial interval and optional max Interval | | ||
| config | [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [RetryBackoffConfig](https://github.com/alex-okrushko/backoff-rxjs/blob/bddb11d6d06d2d2ccdeb12e3c779bc3ae03311db/src/operators/retryBackoff.ts#L6)| required |Can take number as initial interval or a config with initial interval, optional max Interval, optional max number of retry attempts, optional function to cancel reties and optional backoff delay function (exponential by default) | |
@@ -1,2 +0,2 @@ | ||
export {retryBackoffExponential, RetryBackoffExponentialConfig} from './operators/retryBackoffExponential'; | ||
export {intervalBackoffExponential, IntervalBackoffExponentialConfig} from './observable/intervalBackoffExponential'; | ||
export {retryBackoff, RetryBackoffConfig} from './operators/retryBackoff'; | ||
export {intervalBackoff, IntervalBackoffConfig} from './observable/intervalBackoff'; |
@@ -1,5 +0,10 @@ | ||
export function getDelay( | ||
iteration: number, initialInterval: number, maxInterval: number) { | ||
const currentDelay = Math.pow(2, iteration) * initialInterval; | ||
return Math.min(currentDelay, maxInterval); | ||
/** Calculates the actual delay which can be limited by maxInterval */ | ||
export function getDelay(backoffDelay: number, maxInterval: number) { | ||
return Math.min(backoffDelay, maxInterval); | ||
} | ||
/** Exponential backoff delay */ | ||
export function exponentialBackoffDelay( | ||
iteration: number, initialInterval: number) { | ||
return Math.pow(2, iteration) * initialInterval; | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
24611
193
36
1