Reputation: 60875
I'm wondering how node.js oprates if you pipe two different read streams into the same destination at the same time. For example:
var a = fs.createReadStream('a')
var b = fs.createReadStream('b')
var c = fs.createWriteStream('c')
a.pipe(c, {end:false})
b.pipe(c, {end:false})
Does this write a into c, then b into c? Or does it mess everything up?
Upvotes: 5
Views: 2624
Reputation: 338
You want to add the second read into an eventlistener for the first read to finish.
var a = fs.createReadStream('a');
var b = fs.createReadStream('b');
var c = fs.createWriteStream('c');
a.pipe(c, {end:false});
a.on('end', function() {
b.pipe(c)
}
Upvotes: 4