fanout-streams
v1.0.1
Published
Logical grouping of writable-streams in parallel
Downloads
4
Maintainers
Readme
fanout-streams
Logical grouping of writable-streams in parallel
Install
npm install fanout-streams
Use
import { fanoutStreams } from 'fanout-streams'
import { Readable, Writable } from 'readable-stream'
const sink1 = new Writable({
objectMode: true,
write(chunk: string, _: string, callback: (error?: Error \| null) => void) {
console.log('1:', chunk)
callback()
}
})
const sink2 = new Writable({
objectMode: true,
write(chunk: string, _: string, callback: (error?: Error \| null) => void) {
console.log('2:', chunk)
callback()
}
})
const sink3 = new Writable({
objectMode: true,
write(chunk: string, _: string, callback: (error?: Error \| null) => void) {
console.log('3:', chunk)
callback()
}
})
const stream = fanoutStreams(sink1, sink2, sink3)
const publisher = new Readable({objectMode: true, read() {}})
publisher.pipe(stream)
publisher.push('cat')
//=>1: cat
//=>2: cat
//=>3: cat
Related
Logical grouping of transform-streams in series: encapsulate-streams
Index
Functions
Functions
fanoutStreams
▸ fanoutStreams(...streams: Writable
[]): Writable
Defined in fanout-streams.ts:13
Return a single writable stream that fans received chunks out to each input-stream.
Parameters:
| Name | Type |
| ------ | ------ |
| Rest
streams | Writable
[] |
Returns: Writable