-
Notifications
You must be signed in to change notification settings - Fork 56
/
index.d.ts
29 lines (24 loc) · 976 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
declare module 'fetch-retry' {
export type FetchLibrary = (input: any, init?: any) => Promise<any>;
export type RequestDelayFunction<F extends FetchLibrary> = (
attempt: number,
error: Error | null,
response: Awaited<ReturnType<F>> | null,
) => number;
export type RequestRetryOnFunction<F extends FetchLibrary> = (
attempt: number,
error: Error | null,
response: Awaited<ReturnType<F>> | null,
) => boolean | Promise<boolean>;
export type RequestInitRetryParams<F extends FetchLibrary> = {
retries?: number;
retryDelay?: number | RequestDelayFunction<F>;
retryOn?: number[] | RequestRetryOnFunction<F>;
};
export type RequestInitWithRetry<F extends FetchLibrary> = Parameters<F>[1] &
RequestInitRetryParams<F>;
export default function fetchBuilder<F extends FetchLibrary>(
fetch: F,
defaults?: RequestInitRetryParams<F>,
): (input: Parameters<F>[0], init?: RequestInitWithRetry<F>) => ReturnType<F>;
}