export interface AttemptContext { attemptNum: number; attemptsRemaining: number; aborted: boolean; abort: () => void; } export declare type AttemptFunction = (context: AttemptContext, options: AttemptOptions) => Promise; export declare type BeforeAttempt = (context: AttemptContext, options: AttemptOptions) => void; export declare type CalculateDelay = (context: AttemptContext, options: AttemptOptions) => number; export declare type HandleError = (err: any, context: AttemptContext, options: AttemptOptions) => Promise | void; export declare type HandleTimeout = (context: AttemptContext, options: AttemptOptions) => Promise; export interface AttemptOptions { readonly delay: number; readonly initialDelay: number; readonly minDelay: number; readonly maxDelay: number; readonly factor: number; readonly maxAttempts: number; readonly timeout: number; readonly jitter: boolean; readonly initialJitter: boolean; readonly handleError: HandleError | null; readonly handleTimeout: HandleTimeout | null; readonly beforeAttempt: BeforeAttempt | null; readonly calculateDelay: CalculateDelay | null; } export declare type PartialAttemptOptions = { readonly [P in keyof AttemptOptions]?: AttemptOptions[P]; }; export declare function sleep(delay: number): Promise; export declare function defaultCalculateDelay(context: AttemptContext, options: AttemptOptions): number; export declare function retry(attemptFunc: AttemptFunction, attemptOptions?: PartialAttemptOptions): Promise;