@strong-roots-capital/stream-array
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

stream-array Build status npm version codecov

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.

Related

Readme

Keywords

Package Sidebar

Install

npm i @strong-roots-capital/stream-array

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

5.31 kB

Total Files

4

Last publish

Collaborators

  • amchelle
  • hamroctopus