File size: 677 Bytes
fc93158 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | export type FetchMock = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
type FetchPreconnectOptions = {
dns?: boolean;
tcp?: boolean;
http?: boolean;
https?: boolean;
};
type FetchWithPreconnect = {
preconnect: (url: string | URL, options?: FetchPreconnectOptions) => void;
};
export function withFetchPreconnect<T extends typeof fetch>(fn: T): T & FetchWithPreconnect;
export function withFetchPreconnect<T extends object>(
fn: T,
): T & FetchWithPreconnect & typeof fetch;
export function withFetchPreconnect(fn: object) {
return Object.assign(fn, {
preconnect: (_url: string | URL, _options?: FetchPreconnectOptions) => {},
});
}
|