/
index.d.ts
71 lines (68 loc) · 2.79 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/// <reference lib="dom" />
declare const _fetch: typeof fetch;
declare const _Request: typeof Request;
declare const _Response: typeof Response;
declare const _Headers: typeof Headers;
declare const _FormData: typeof FormData;
declare const _AbortController: typeof AbortController;
declare const _ReadableStream: typeof ReadableStream;
declare const _WritableStream: typeof WritableStream;
declare const _TransformStream: typeof TransformStream;
declare const _Blob: typeof Blob;
declare const _File: typeof File;
declare const _crypto: typeof crypto;
declare const _btoa: typeof btoa;
declare const _TextEncoder: typeof TextEncoder;
declare const _TextDecoder: typeof TextDecoder;
declare module "@whatwg-node/fetch" {
export const fetch: typeof _fetch;
export const Request: typeof _Request;
export const Response: typeof _Response;
export const Headers: typeof _Headers;
export const FormData: typeof _FormData;
export const AbortController: typeof _AbortController;
export const ReadableStream: typeof _ReadableStream;
export const WritableStream: typeof _WritableStream;
export const TransformStream: typeof _TransformStream;
export const Blob: typeof _Blob;
export const File: typeof _File;
export const crypto: typeof _crypto;
export const btoa: typeof _btoa;
export const TextDecoder: typeof _TextDecoder;
export const TextEncoder: typeof _TextEncoder;
export interface FormDataLimits {
/* Max field name size (in bytes). Default: 100. */
fieldNameSize?: number;
/* Max field value size (in bytes). Default: 1MB. */
fieldSize?: number;
/* Max number of fields. Default: Infinity. */
fields?: number;
/* For multipart forms, the max file size (in bytes). Default: Infinity. */
fileSize?: number;
/* For multipart forms, the max number of file fields. Default: Infinity. */
files?: number;
/* For multipart forms, the max number of parts (fields + files). Default: Infinity. */
parts?: number;
/* For multipart forms, the max number of header key-value pairs to parse. Default: 2000. */
headerSize?: number;
/* For multipart forms, enable this if your data has fields first, then files. Default: false. */
fieldsFirst?: boolean;
}
export const createFetch: (opts?: { useNodeFetch?: boolean; formDataLimits?: FormDataLimits }) => ({
fetch: typeof _fetch,
Request: typeof _Request,
Response: typeof _Response,
Headers: typeof _Headers,
FormData: typeof _FormData,
AbortController: typeof _AbortController,
ReadableStream: typeof _ReadableStream,
WritableStream: typeof _WritableStream,
TransformStream: typeof _TransformStream,
Blob: typeof _Blob,
File: typeof _File,
crypto: typeof _crypto,
btoa: typeof _btoa,
TextEncoder: typeof _TextEncoder,
TextDecoder: typeof _TextDecoder
});
}