backoff-rxjs
Version:
A collection of helpful RxJS operators to deal with backoff strategies (like exponential backoff)
13 lines (11 loc) • 368 B
text/typescript
/** 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;
}