-
Notifications
You must be signed in to change notification settings - Fork 96
/
index.d.ts
61 lines (52 loc) · 1.33 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
export type XhrCallback = (
error: Error,
response: XhrResponse,
body: any
) => void;
export interface XhrResponse {
body: Object | string;
statusCode: number;
method: string;
headers: XhrHeaders;
url: string;
rawRequest: XMLHttpRequest;
}
export interface XhrHeaders {
[key: string]: string;
}
export interface XhrBaseConfig {
useXDR?: boolean;
sync?: boolean;
method?: 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'POST' | 'PUT' | 'PATCH';
timeout?: number;
headers?: XhrHeaders;
body?: string | any;
json?: boolean;
username?: string;
password?: string;
withCredentials?: boolean;
responseType?: '' | 'arraybuffer' | 'blob' | 'document' | 'json' | 'text';
beforeSend?: (xhrObject: XMLHttpRequest) => void;
xhr?: XMLHttpRequest;
}
export interface XhrUriConfig extends XhrBaseConfig {
uri: string;
}
export interface XhrUrlConfig extends XhrBaseConfig {
url: string;
}
export interface XhrInstance {
(options: XhrUriConfig | XhrUrlConfig, callback: XhrCallback): any;
(url: string, callback: XhrCallback): any;
(url: string, options: XhrBaseConfig, callback: XhrCallback): any;
}
export interface XhrStatic extends XhrInstance {
del: XhrInstance;
get: XhrInstance;
head: XhrInstance;
patch: XhrInstance;
post: XhrInstance;
put: XhrInstance;
}
declare const Xhr: XhrStatic;
export default Xhr;