(opts)
| 3 | import { normalize_options } from "./api/normalize_options.js"; |
| 4 | |
| 5 | const 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 | |
| 37 | export { parse, CsvError, normalize_options }; |
no test coverage detected