This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const backoff = (config?: { readonly scale?: number; readonly count?: number; }): readonly number[] => { | |
return [...Array(config?.count ?? 4).keys()].map(item => 2 ** item * (config?.scale ?? 1)); | |
} | |
const backoff$ = (config?: { readonly delay?: number; readonly count?: number; readonly scale?: number;}) => { | |
return from([...Array(config?.count ?? 4).keys()]).pipe( | |
concatMap(next => timer((config?.scale ?? 2) ** next * (config?.delay ?? 500))) | |
) | |
} |
OlderNewer