1import { RequestInfo, RequestInit, Response } from 'node-fetch';
2import { URLSearchParams } from 'url';
3
4export type ProgressCallback = (props: {
5  /** Number ranging from 0 to 1 representing the download percentage. */
6  progress: number;
7  /** Total size of the download, in bytes. */
8  total: number;
9  /** Current amount of data downloaded, in bytes. */
10  loaded: number;
11}) => void;
12
13/**
14 * Represents a `fetch`-like function. Used since `typeof fetch` has statics we don't
15 * use and aren't interested in hoisting every time we wrap fetch with extra features.
16 */
17export type FetchLike = (
18  url: RequestInfo,
19  init?: RequestInit & {
20    searchParams?: URLSearchParams;
21    /** Progress callback, only implemented when `wrapFetchWithProgress` is used. */
22    onProgress?: ProgressCallback;
23  }
24) => Promise<Response>;
25