A JavaScript package that helps to reads and processes a stream line-by-line in order or in batches in parallel.
$ npm install --save @rpidanny/streamline.js| Parameters | Default | Description |
|---|---|---|
readStream |
None |
Any Node.js ReadStream object |
handler |
None |
A processing function that is called on every line of the stream with the line as the argument |
concurrency |
1 |
The number of concurrent execution of the handler |
| Parameters | Default | Description |
|---|---|---|
readStream |
None |
Any Node.js ReadStream object |
handler |
None |
A processing function that is called on every line of the stream with the parsed JSON object as the argument |
concurrency |
1 |
The number of concurrent execution of the handler |
| Parameters | Default | Description |
|---|---|---|
readStream |
None |
Any Node.js ReadStream object |
handler |
None |
A processing function that is called on every line of the stream with the parsed CSV as the argument |
concurrency |
1 |
The number of concurrent execution of the handler |
const readStream = fs.createReadStream(`jsonlFile.json`)
await processJson(
readStream,
async (item: Record<string, unknown>) => {
console.log(item)
},
2,
)StreamlineStreamlineCsvStreamlineJson
These are abstract classes that can be inherited to create complex classes to process read streams.
These classes are derived from Base classes which is suitable for some common use cases.
SimpleCsvProcessorSimpleJsonProcessorSimpleCsvProcessor