This repository has been archived by the owner on Aug 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.d.ts
129 lines (108 loc) · 3.16 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import Undici from 'undici'
declare const fetch: {
(
resource: string | Request | URL,
init?: RequestInit
): Promise<Response>
Request: Request
Response: Response
Headers: Headers
Body: Body
setGlobalDispatcher: typeof Undici.setGlobalDispatcher
getGlobalDispatcher: typeof Undici.getGlobalDispatcher
}
declare class ControlledAsyncIterable<Data> implements AsyncIterable<Data> {
constructor (input: AsyncIterable<Data> | Iterable<Data>)
data: AsyncIterable<Data>
disturbed: boolean
[Symbol.asyncIterator] (): AsyncIterator<Data>
}
type BodyInput<Data = unknown> = AsyncIterable<Data> | Iterable<Data> | null | undefined
interface BodyMixin<Data = unknown> {
readonly body: ControlledAsyncIterable<Data> | null
readonly bodyUsed: boolean
arrayBuffer: () => Promise<Buffer>
blob: () => never
formData: () => never
json: () => Promise<any>
text: () => Promise<string>
}
type HeadersInit = Headers | Iterable<[string, string]> | string[] | Record<string, string> | undefined
declare class Headers implements Iterable<[string, string]> {
constructor (init?: HeadersInit);
append (name: string, value: string): void;
delete (name: string): void;
get (name: string): string | null;
has (name: string): boolean;
set (name: string, value: string): void;
entries (): IterableIterator<[string, string]>;
forEach (
callbackfn: (value: string, key: string, iterable: Headers) => void,
thisArg?: any
): void;
keys (): IterableIterator<string>;
values (): IterableIterator<string>;
[Symbol.iterator] (): Iterator<[string, string]>;
}
interface RequestInit {
method?: string
keepalive?: boolean
headers?: Headers | HeadersInit
body?: BodyInput
redirect?: string
integrity?: string
signal?: AbortSignal
}
declare class Request<Data = unknown> implements BodyMixin {
constructor (input: Request | string | URL, init?: RequestInit);
readonly url: URL
readonly method: string
readonly headers: Headers
readonly redirect: string
readonly integrity: string
readonly keepalive: boolean
readonly signal: AbortSignal
readonly body: ControlledAsyncIterable<Data> | null
readonly bodyUsed: boolean
arrayBuffer (): Promise<Buffer>;
blob (): never;
formData (): never;
json (): Promise<any>;
text (): Promise<string>;
clone (): Request;
}
interface ResponseInit {
status?: number
statusText?: string
headers?: Headers | HeadersInit
}
declare class Response<Data = unknown> implements BodyMixin {
constructor (body: BodyInput, init?: ResponseInit)
readonly headers: Headers
readonly ok: boolean
readonly status: number
readonly statusText: string
readonly type: string
readonly url: string
readonly redirected: boolean
readonly body: ControlledAsyncIterable<Data> | null
readonly bodyUsed: boolean
arrayBuffer (): Promise<Buffer>;
blob (): never;
formData (): never;
json (): Promise<any>;
text (): Promise<string>;
clone (): Response;
static error (): Response;
static redirect (url: string, status: number): Response;
}
export default fetch
export { setGlobalDispatcher, getGlobalDispatcher } from 'undici'
export type {
BodyMixin
}
export {
Headers,
Request,
Response
}