-
-
Notifications
You must be signed in to change notification settings - Fork 135
/
index.test-d.ts
40 lines (37 loc) · 1.53 KB
/
index.test-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
import { expectType } from 'tsd';
import csvParser = require('.');
const options: csvParser.Options = {};
expectType<csvParser.CsvParser>(csvParser(['Name', 'Age']));
expectType<csvParser.CsvParser>(csvParser({ escape: '"' }));
expectType<csvParser.CsvParser>(csvParser({ headers: ['Name', 'Age'] }));
expectType<csvParser.CsvParser>(csvParser({ headers: false }));
expectType<csvParser.CsvParser>(
csvParser({
mapHeaders: ({ header, index }) => {
expectType<string>(header);
expectType<number>(index);
return header.toLowerCase();
},
})
);
expectType<csvParser.CsvParser>(csvParser({ mapHeaders: ({ header, index }) => null }));
expectType<csvParser.CsvParser>(
csvParser({
mapValues: ({ header, index, value }) => {
expectType<string>(header);
expectType<number>(index);
expectType<any>(value);
return value.toLowerCase();
},
})
);
expectType<csvParser.CsvParser>(csvParser({ mapValues: ({ header, index, value }) => null }));
expectType<csvParser.CsvParser>(csvParser({ newline: '\n' }));
expectType<csvParser.CsvParser>(csvParser({ quote: '"' }));
expectType<csvParser.CsvParser>(csvParser({ raw: true }));
expectType<csvParser.CsvParser>(csvParser({ separator: ',' }));
expectType<csvParser.CsvParser>(csvParser({ skipComments: true }));
expectType<csvParser.CsvParser>(csvParser({ skipComments: '#' }));
expectType<csvParser.CsvParser>(csvParser({ skipLines: 1 }));
expectType<csvParser.CsvParser>(csvParser({ maxRowBytes: 1 }));
expectType<csvParser.CsvParser>(csvParser({ strict: true }));