UNPKG

618 BTypeScriptView Raw
1import { RequestInit, Response } from "node-fetch";
2declare type Url<S extends string> = S extends `http${infer A}` ? S : never;
3declare type IsUrl<S extends string> = Url<S> extends never ? false : true;
4declare type Extname<S extends string> = S extends `${infer A}.${infer B}` ? B : never;
5declare type HasExt<S extends string> = Extname<S> extends never ? false : true;
6interface DirOptions {
7 recursive?: boolean;
8}
9declare function fetch<T extends string, Opts = IsUrl<T> extends true ? RequestInit : HasExt<T> extends true ? never : DirOptions>(url: T, opts?: Opts): Promise<Response>;
10export default fetch;