This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.d.ts
84 lines (63 loc) · 4.43 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
// Type definitions for D3JS d3-request module v1.0.2
// Project: https://github.com/d3/d3-request/
// Definitions by: Hugues Stefanski <https://github.com/Ledragon>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { DSVParsedArray, DSVRowString, DSVRowAny } from '../d3-dsv';
export interface Request {
abort(): this;
get(): this;
get<RequestData>(data: RequestData): this;
get<ResponseData>(callback: (error: any, d: ResponseData) => void): this;
get<RequestData, ResponseData>(data: RequestData, callback: (error: any, d: ResponseData) => void): this;
header(name: string): string;
header(name: string, value: string | null): this;
mimeType(): string | null;
mimeType(value: string | null): this;
on(type: 'beforesend'): (this: this, xhr: XMLHttpRequest) => void;
on(type: 'progress'): (this: this, progressEvent: ProgressEvent) => void;
on(type: 'error'): (this: this, error: any) => void;
on<ResponseData>(type: 'load'): (this: this, data: ResponseData) => void;
on(type: string): (this: this, data: any) => void;
on(type: string, listener: null): this;
on(type: 'beforesend', listener: (this: this, xhr: XMLHttpRequest) => void): this;
on(type: 'progress', listener: (this: this, progressEvent: ProgressEvent) => void): this;
on(type: 'error', listener: (this: this, error: any) => void): this;
on<ResponseData>(type: 'load', listener: (this: this, data: ResponseData) => void): this;
on(type: string, listener: (this: this, data: any) => void): this;
password(): string | null;
password(value: string): this;
post(): this;
post<RequestData>(data: RequestData): this;
post<ResponseData>(callback: (this: this, error: any, d: ResponseData) => void): this;
post<RequestData, ResponseData>(data: RequestData, callback: (this: this, error: any, d: ResponseData) => void): this;
response<ResponseData>(callback: (this: this, response: XMLHttpRequest) => ResponseData): this;
responseType(): string | null;
responseType(value: string): this;
send(method: string): this;
send<RequestData>(method: string, data: RequestData): this;
send<ResponseData>(method: string, callback: (this: this, error: any | null, d: ResponseData | null) => void): this;
send<RequestData, ResponseData>(method: string, data: RequestData, callback: (this: this, error: any | null, d: ResponseData | null) => void): this;
timeout(): number;
timeout(value: number): this;
user(): string | null;
user(value: string): this;
}
export interface DsvRequest extends Request {
row<ParsedRow extends DSVRowAny>(value: (rawRow: DSVRowString, index: number, columns: Array<string>) => ParsedRow): DsvRequest;
}
export function csv(url: string): DsvRequest;
export function csv(url: string, callback: (this: DsvRequest, error: any, d: DSVParsedArray<DSVRowString>) => void): DsvRequest;
export function csv<ParsedRow extends DSVRowAny>(url: string, row: (rawRow: DSVRowString, index: number, columns: Array<string>) => ParsedRow, callback: (this: DsvRequest, error: any, d: DSVParsedArray<ParsedRow>) => void): DsvRequest;
export function html(url: string): Request;
export function html(url: string, callback: (this: Request, error: any, d: DocumentFragment) => void): Request;
export function json(url: string): Request;
export function json<ParsedObject extends { [key: string]: any }>(url: string, callback: (this: Request, error: any, d: ParsedObject) => void): Request;
export function request(url: string): Request;
export function request(url: string, callback: (this: Request, error: any, d: XMLHttpRequest) => void): Request;
export function text(url: string): Request;
export function text(url: string, callback: (this: Request, error: any, d: string) => void): Request;
export function tsv(url: string): DsvRequest;
export function tsv(url: string, callback: (this: DsvRequest, error: any, d: DSVParsedArray<DSVRowString>) => void): DsvRequest;
export function tsv<ParsedRow extends DSVRowAny>(url: string, row: (rawRow: DSVRowString, index: number, columns: Array<string>) => ParsedRow, callback: (this: DsvRequest, error: any, d: DSVParsedArray<ParsedRow>) => void): DsvRequest;
export function xml(url: string): Request;
export function xml(url: string, callback: (this: Request, error: any, d: any) => void): Request;