Licence
ISC
Version
1.0.0
Deps
3
Size
5 kB
Vulns
0
Weekly
0
stream-array

Pipe an array through a stream
Install
npm install @strong-roots-capital/stream-array
Use
import streamArray from '@strong-roots-capital/stream-array'
import { Writable } from 'readable-stream'
const array = [0, 1, 2, 3, 4, 5]
const sink = new Writable({
objectMode: true,
write(chunk: number, _: string, callback: (error?: Error | null) => void) {
console.log(chunk)
callback()
}
})
sink.on('finish', () => console.log('fin'))
streamArray(array).pipe(sink)
//=>0
//=>1
//=>2
//=>3
//=>4
//=>5
//=>fin
Note that objectMode is true.