exponential-backoff
Version:
A utility that allows retrying a function with an exponential delay between attempts.
17 lines (13 loc) • 384 B
text/typescript
import { IBackOffOptions } from "../options";
import { fullJitter } from "./full/full.jitter";
import { noJitter } from "./no/no.jitter";
export type Jitter = (delay: number) => number;
export function JitterFactory(options: IBackOffOptions): Jitter {
switch (options.jitter) {
case "full":
return fullJitter;
case "none":
default:
return noJitter;
}
}