Class LexerTransformer

A transform stream that converts a stream of tokens into a stream of rows.

Example: Parse a CSV with headers by data

new ReadableStream({
start(controller) {
controller.enqueue("name,age\r\n");
controller.enqueue("Alice,20\r\n");
controller.close();
}
})
.pipeThrough(new LexerTransformer())
.pipeTo(new WritableStream({ write(tokens) {
for (const token of tokens) {
console.log(token);
}
}}));
// { type: Field, value: "name" }
// FieldDelimiter
// { type: Field, value: "age" }
// RecordDelimiter
// { type: Field, value: "Alice" }
// FieldDelimiter
// { type: Field, value: "20" }
// RecordDelimiter

Hierarchy

Constructors

Properties

Constructors

Properties

readable: ReadableStream<Token[]>
writable: WritableStream<string>

Generated using TypeDoc