-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.d.ts
More file actions
71 lines (64 loc) · 2.38 KB
/
index.d.ts
File metadata and controls
71 lines (64 loc) · 2.38 KB
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
declare module 'csvdata' {
export type Encoding = 'hex' |
'utf8' |
'ucs2' |
'ascii' |
'base64' |
'latin1' |
'binary' |
'utf16le'
export type CSVData = string |
object |
string[] |
object[] |
string[][]
export interface LoadOptions {
readonly log?: boolean;
readonly parse?: boolean;
readonly stream?: boolean;
readonly objName?: boolean;
readonly delimiter?: string;
readonly encoding?: Encoding;
}
export interface WriteOptions {
readonly log?: boolean;
readonly empty?: boolean;
readonly header?: string;
readonly append?: boolean;
readonly delimiter?: string;
readonly encoding?: Encoding;
}
export interface CheckOptions {
readonly log?: boolean;
readonly limit?: boolean;
readonly delimiter?: string;
readonly encoding?: Encoding;
readonly duplicates?: boolean;
readonly emptyLines?: boolean;
}
/**
* Reads the CSV data (the first line of the CSV file must contain headers)
*
* @param filePath Where the CSV is stored
* @param options Configurations to how to read this file
* @returns The read data
*/
export function load(filePath: string, options: LoadOptions): Promise<CSVData[]>;
/**
* Writes the data (be careful, as it overwrites existing files)
*
* @param filePath Where the CSV will be stored
* @param data What to write
* @param options Configurations to how to write this file
* @returns The same data that was sent to be written
*/
export function write(filePath: string, data: CSVData, options?: WriteOptions): Promise<CSVData[]>;
/**
* Checks data integrity of the CSV file. It can look for missing, empty, and duplicate values within columns, or detect empty lines
*
* @param filePath Where the CSV is stored
* @param options Configurations to how to check this file
* @returns Whether or not the file is like the specified way
*/
export function check(filePath: string, options?: CheckOptions): Promise<Boolean>;
}