MCPcopy
hub / github.com/adaltas/node-csv / parse

Function parse

packages/csv-parse/lib/stream.js:5–35  ·  view source on GitHub ↗
(opts)

Source from the content-addressed store, hash-verified

3import { normalize_options } from "./api/normalize_options.js";
4
5const parse = (opts) => {
6 const api = transform(opts);
7 let controller;
8 const enqueue = (record) => {
9 controller.enqueue(record);
10 };
11 const terminate = () => {
12 controller.terminate();
13 };
14 return new TransformStream(
15 {
16 start(ctr) {
17 controller = ctr;
18 },
19 transform(chunk) {
20 const error = api.parse(chunk, false, enqueue, terminate);
21 if (error) {
22 controller.error(error);
23 }
24 },
25 flush() {
26 const error = api.parse(undefined, true, enqueue, terminate);
27 if (error) {
28 controller.error(error);
29 }
30 },
31 },
32 new CountQueuingStrategy({ highWaterMark: 1024 }),
33 new CountQueuingStrategy({ highWaterMark: 1024 }),
34 );
35};
36
37export { parse, CsvError, normalize_options };

Callers 1

parse_stream.tsFile · 0.90

Calls 1

transformFunction · 0.90

Tested by

no test coverage detected