Created
January 6, 2019 15:42
-
-
Save smashingpat/dbd0d4358e27951b55b23757c32f0647 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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