npm install --save input-stream
or
yarn add input-stream
The input stream functions as an async iterator, so each item can be awaited in a for
loop.
const input = require('input-stream')('data/example.csv')
for await (const item of input) {
console.log(item)
}
Options provided as a second parameter will be passed through to csv-parser.
const input = require('input-stream')('data/example.tsv')
for await (const item of input) {
console.log(item)
}
Options provided as a second parameter will be passed through to csv-parser, apart from separator
.
const input = require('input-stream')('data/example.ndjson')
for await (const item of input) {
console.log(item)
}
const input = require('input-stream')('data/example.xml', {
element: 'foo'
})
for await (const item of input) {
console.log(item)
}
Options provided as a second parameter will be passed through to xml-stream, apart from output
.
An example of piping the input stream directly to output-stream, for conversion between formats.
const input = require('input-stream')('data/example.csv')
const output = require('output-stream')('data/example.ndjson')
input.pipe(output)