Skip to content

Instantly share code, notes, and snippets.

@smashingpat
Created January 6, 2019 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smashingpat/dbd0d4358e27951b55b23757c32f0647 to your computer and use it in GitHub Desktop.
Save smashingpat/dbd0d4358e27951b55b23757c32f0647 to your computer and use it in GitHub Desktop.
const { PassThrough } = require('stream');
function combineStream(...streams) {
return streams.reduce((passthrough, stream, i) => {
stream.pipe(passthrough);
stream.once('end', () => {
streams.every(s => s.ended);
passthrough.emit('end');
});
return passthrough;
}, new PassThrough());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment