2026-02-17 09:43:41 -05:00
|
|
|
export type FetchMock = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
|
|
|
|
|
|
|
|
type FetchPreconnectOptions = {
|
|
|
|
|
dns?: boolean;
|
|
|
|
|
tcp?: boolean;
|
|
|
|
|
http?: boolean;
|
|
|
|
|
https?: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-17 14:34:41 +00:00
|
|
|
type FetchWithPreconnect = {
|
2026-02-17 09:43:41 -05:00
|
|
|
preconnect: (url: string | URL, options?: FetchPreconnectOptions) => void;
|
2026-02-17 14:34:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function withFetchPreconnect<T extends typeof fetch>(fn: T): T & FetchWithPreconnect;
|
|
|
|
|
export function withFetchPreconnect<T extends object>(
|
2026-02-17 09:01:30 -05:00
|
|
|
fn: T,
|
2026-02-17 14:34:41 +00:00
|
|
|
): T & FetchWithPreconnect & typeof fetch;
|
|
|
|
|
export function withFetchPreconnect(fn: object) {
|
|
|
|
|
return Object.assign(fn, {
|
2026-02-17 09:43:41 -05:00
|
|
|
preconnect: (_url: string | URL, _options?: FetchPreconnectOptions) => {},
|
2026-02-17 14:34:41 +00:00
|
|
|
});
|
|
|
|
|
}
|