forked from sindresorhus/neat-csv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
36 lines (27 loc) · 946 Bytes
/
Copy pathindex.d.ts
File metadata and controls
36 lines (27 loc) · 946 Bytes
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
/// <reference types="node"/>
import {Readable as ReadableStream} from 'stream';
import {Options as CsvParserOptions} from 'csv-parser';
declare namespace neatCsv {
type Options = CsvParserOptions;
type Row = Record<string, string>;
}
/**
Fast CSV parser.
Convenience wrapper around the super-fast streaming [`csv-parser`](https://github.com/mafintosh/csv-parser) module. Use that one if you want streamed parsing.
@param data - CSV data to parse.
@param options - See the [`csv-parser` options](https://github.com/mafintosh/csv-parser#options).
@example
```
import neatCsv = require('neat-csv');
const csv = 'type,part\nunicorn,horn\nrainbow,pink';
(async () => {
console.log(await neatCsv(csv));
//=> [{type: 'unicorn', part: 'horn'}, {type: 'rainbow', part: 'pink'}]
})();
```
*/
declare function neatCsv<Row = neatCsv.Row>(
data: string | Buffer | ReadableStream,
options?: neatCsv.Options
): Promise<Row[]>;
export = neatCsv;