2 streams:
Given readable streams stream1
and stream2
, what\'s an idiomatic (concise) way to get a stream containing
If you don't care about the ordering of data in the streams, a simple reduce operation should be fine in nodejs!
const {PassThrough} = require('stream')
let joined = [s0, s1, s2, ...sN].reduce((pt, s, i, a) => {
s.pipe(pt, {end: false})
s.once('end', () => a.every(s => s.ended) && pt.emit('end'))
return pt
}, new PassThrough())
Cheers ;)