index.d.ts 815 B

12345678910111213141516171819202122232425262728
  1. /// <reference lib="dom" />
  2. declare module 'fetch-retry' {
  3. const _fetch: typeof fetch;
  4. type RequestDelayFunction = ((
  5. attempt: number,
  6. error: Error | null,
  7. response: Response | null
  8. ) => number);
  9. type RequestRetryOnFunction = ((
  10. attempt: number,
  11. error: Error | null,
  12. response: Response | null
  13. ) => boolean | Promise<boolean>);
  14. export interface RequestInitRetryParams {
  15. retries?: number;
  16. retryDelay?: number | RequestDelayFunction;
  17. retryOn?: number[] | RequestRetryOnFunction;
  18. }
  19. export type RequestInitWithRetry = RequestInit & RequestInitRetryParams;
  20. function fetchBuilder(fetch: typeof _fetch, defaults?: RequestInitRetryParams): ((input: Parameters<typeof _fetch>[0], init?: RequestInitWithRetry) => Promise<Response>);
  21. export default fetchBuilder;
  22. }