This can be done with vanilla Node.js
import { PassThrough } from 'stream'
const merge = (...streams) => {
let pass = new PassThrough()
for (let stream of streams) {
const end = stream == streams.at(-1);
pass = stream.pipe(pass, { end })
}
return pass
}
Use streams.slice(-1)[0]
if you don’t have .at()
in your version of Node.js