A transform stream that converts a stream of tokens into a stream of rows.
The options for the parser.
new ReadableStream({ start(controller) { controller.enqueue("name,age\r\n"); controller.enqueue("Alice,20\r\n"); controller.enqueue("Bob,25\r\n"); controller.enqueue("Charlie,30\r\n"); controller.close(); }) .pipeThrough(new LexerTransformer()) .pipeThrough(new RecordAssemblerTransformer()) .pipeTo(new WritableStream({ write(row) { console.log(row); }}));// { name: "Alice", age: "20" }// { name: "Bob", age: "25" }// { name: "Charlie", age: "30" } Copy
new ReadableStream({ start(controller) { controller.enqueue("name,age\r\n"); controller.enqueue("Alice,20\r\n"); controller.enqueue("Bob,25\r\n"); controller.enqueue("Charlie,30\r\n"); controller.close(); }) .pipeThrough(new LexerTransformer()) .pipeThrough(new RecordAssemblerTransformer()) .pipeTo(new WritableStream({ write(row) { console.log(row); }}));// { name: "Alice", age: "20" }// { name: "Bob", age: "25" }// { name: "Charlie", age: "30" }
new ReadableStream({ start(controller) { controller.enqueue("Alice,20\r\n"); controller.enqueue("Bob,25\r\n"); controller.enqueue("Charlie,30\r\n"); controller.close(); }}).pipeThrough(new LexerTransformer()).pipeThrough(new RecordAssemblerTransformer({ header: ["name", "age"] })).pipeTo(new WritableStream({ write(row) { console.log(row); }}));// { name: "Alice", age: "20" }// { name: "Bob", age: "25" }// { name: "Charlie", age: "30" } Copy
new ReadableStream({ start(controller) { controller.enqueue("Alice,20\r\n"); controller.enqueue("Bob,25\r\n"); controller.enqueue("Charlie,30\r\n"); controller.close(); }}).pipeThrough(new LexerTransformer()).pipeThrough(new RecordAssemblerTransformer({ header: ["name", "age"] })).pipeTo(new WritableStream({ write(row) { console.log(row); }}));// { name: "Alice", age: "20" }// { name: "Bob", age: "25" }// { name: "Charlie", age: "30" }
The type of the header row.
Readonly
MDN Reference
A transform stream that converts a stream of tokens into a stream of rows.
Param: options
The options for the parser.
Example: Parse a CSV with headers by data
Example: Parse a CSV with headers by options