1st version
This commit is contained in:
36
Jira_helper/node_modules/csv-parse/lib/stream.js
generated
vendored
Normal file
36
Jira_helper/node_modules/csv-parse/lib/stream.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { TransformStream, CountQueuingStrategy } from "node:stream/web";
|
||||
import { transform } from "./api/index.js";
|
||||
|
||||
const parse = (opts) => {
|
||||
const api = transform(opts);
|
||||
let controller;
|
||||
const enqueue = (record) => {
|
||||
controller.enqueue(record);
|
||||
};
|
||||
const terminate = () => {
|
||||
controller.terminate();
|
||||
};
|
||||
return new TransformStream(
|
||||
{
|
||||
start(ctr) {
|
||||
controller = ctr;
|
||||
},
|
||||
transform(chunk) {
|
||||
const error = api.parse(chunk, false, enqueue, terminate);
|
||||
if (error) {
|
||||
controller.error(error);
|
||||
}
|
||||
},
|
||||
flush() {
|
||||
const error = api.parse(undefined, true, enqueue, terminate);
|
||||
if (error) {
|
||||
controller.error(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
new CountQueuingStrategy({ highWaterMark: 1024 }),
|
||||
new CountQueuingStrategy({ highWaterMark: 1024 }),
|
||||
);
|
||||
};
|
||||
|
||||
export { parse };
|
||||
Reference in New Issue
Block a user