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
82 lines (57 loc) · 4.13 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
// Type definitions for D3JS d3-dsv module v1.0.1
// Project: https://github.com/d3/d3-dsv/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// ------------------------------------------------------------------------------------------
// Shared Types and Interfaces
// ------------------------------------------------------------------------------------------
export interface DSVRowString {
[key: string]: string;
}
export interface DSVRowAny {
[key: string]: any;
}
export interface DSVParsedArray<T> extends Array<T> {
columns: Array<string>;
}
// ------------------------------------------------------------------------------------------
// CSV Parsers and Formatters
// ------------------------------------------------------------------------------------------
// csvParse(...) ============================================================================
export function csvParse(csvString: string): DSVParsedArray<DSVRowString>;
export function csvParse<ParsedRow extends DSVRowAny>(csvString: string, row: (rawRow: DSVRowString, index: number, columns: Array<string>) => ParsedRow): DSVParsedArray<ParsedRow>;
// csvParseRows(...) ========================================================================
export function csvParseRows(csvString: string): Array<Array<string>>;
export function csvParseRows<ParsedRow extends DSVRowAny>(csvString: string, row: (rawRow: Array<string>, index: number) => ParsedRow): Array<ParsedRow>;
// csvFormat(...) ============================================================================
export function csvFormat(rows: Array<DSVRowAny>): string;
export function csvFormat(rows: Array<DSVRowAny>, columns: Array<string>): string;
// csvFormatRows(...) ========================================================================
export function csvFormatRows(rows: Array<Array<string>>): string;
// ------------------------------------------------------------------------------------------
// TSV Parsers and Formatters
// ------------------------------------------------------------------------------------------
// tsvParse(...) ============================================================================
export function tsvParse(tsvString: string): DSVParsedArray<DSVRowString>;
export function tsvParse<MappedRow extends DSVRowAny>(tsvString: string, row: (rawRow: DSVRowString, index: number, columns: Array<string>) => MappedRow): DSVParsedArray<MappedRow>;
// tsvParseRows(...) ========================================================================
export function tsvParseRows(tsvString: string): Array<Array<string>>;
export function tsvParseRows<MappedRow extends DSVRowAny>(tsvString: string, row: (rawRow: Array<string>, index: number) => MappedRow): Array<MappedRow>;
// tsvFormat(...) ============================================================================
export function tsvFormat(rows: Array<DSVRowAny>): string;
export function tsvFormat(rows: Array<DSVRowAny>, columns: Array<string>): string;
// tsvFormatRows(...) ========================================================================
export function tsvFormatRows(rows: Array<Array<string>>): string;
// ------------------------------------------------------------------------------------------
// DSV Generalized Parsers and Formatters
// ------------------------------------------------------------------------------------------
export interface DSV {
parse(dsvString: string): DSVParsedArray<DSVRowString>;
parse<ParsedRow extends DSVRowAny>(dsvString: string, row: (rawRow: DSVRowString, index: number, columns: Array<string>) => ParsedRow): DSVParsedArray<ParsedRow>;
parseRows(dsvString: string): Array<Array<string>>;
parseRows<ParsedRow extends DSVRowAny>(dsvString: string, row: (rawRow: Array<string>, index: number) => ParsedRow): Array<ParsedRow>;
format(rows: Array<DSVRowAny>): string;
format(rows: Array<DSVRowAny>, columns: Array<string>): string;
formatRows(rows: Array<Array<string>>): string;
}
export function dsvFormat(delimiter: string): DSV;