The type of the header row
The parser options type
Optionaloptions: OptionsCSV parser options including header, delimiter, outputFormat, engine, etc.
OptionalstreamOptions: StringCSVParserStreamOptionsStream-specific options like backpressureCheckInterval
OptionalwritableStrategy: QueuingStrategy<string>Strategy for the writable side (default: { highWaterMark: 65536, size: chunk => chunk.length })
OptionalreadableStrategy: QueuingStrategy<CSVRecord<Header, InferFormat<Options>>>Strategy for the readable side (default: { highWaterMark: 256, size: () => 1 })
A StringCSVParserStream instance configured with the specified options
Choosing the Right API for guidance on selecting the appropriate API level.
import { createStringCSVParserStream } from 'web-csv-toolbox';
await fetch('data.csv')
.then(res => res.body)
.pipeThrough(new TextDecoderStream())
.pipeThrough(createStringCSVParserStream())
.pipeTo(new WritableStream({
write(record) {
console.log(record); // { name: 'Alice', age: '30' }
}
}));
import { createStringCSVParserStream } from 'web-csv-toolbox';
// CSV data without header row
const stream = createStringCSVParserStream({
header: ['name', 'age']
});
stringStream
.pipeThrough(stream)
.pipeTo(yourProcessor);
import { createStringCSVParserStream } from 'web-csv-toolbox';
const stream = createStringCSVParserStream({
outputFormat: 'array'
});
stringStream
.pipeThrough(stream)
.pipeTo(new WritableStream({
write(record) {
console.log(record); // ['Alice', '30']
}
}));
import { createStringCSVParserStream } from 'web-csv-toolbox';
const tsvStream = createStringCSVParserStream({
delimiter: '\t'
});
tsvStringStream.pipeThrough(tsvStream);
import { createStringCSVParserStream } from 'web-csv-toolbox';
const stream = createStringCSVParserStream(
{ header: ['name', 'age'] },
{ backpressureCheckInterval: 50 },
{ highWaterMark: 131072, size: (chunk) => chunk.length },
new CountQueuingStrategy({ highWaterMark: 512 })
);
await fetch('large-file.csv')
.then(res => res.body)
.pipeThrough(new TextDecoderStream())
.pipeThrough(stream)
.pipeTo(yourProcessor);
Factory function to create a StringCSVParserStream instance.
This function internally creates a StringCSVParser and wraps it in a StringCSVParserStream, providing a simpler API for stream-based CSV parsing from string streams.