Created
July 7, 2016 22:13
-
-
Save phated/10d95bb38ed104ce00bf564d3b3f9ac2 to your computer and use it in GitHub Desktop.
Streams confusion
This file contains hidden or 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
| // This doesn't work because I use { end: false } but I need the fd | |
| var fs = require('fs'); | |
| var outStream = fs.createWriteStream('out-file.txt'); | |
| outStream.once('finish', function() { | |
| console.log('finish'); | |
| outStream.end(); | |
| }); | |
| var inStream = fs.createReadStream('file.txt'); | |
| inStream.pipe(outStream, { end: false }); |
This file contains hidden or 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
| // This works when I remove { end: false } but it closes the fd | |
| var fs = require('fs'); | |
| var outStream = fs.createWriteStream('out-file.txt'); | |
| outStream.once('finish', function() { | |
| console.log('finish'); | |
| outStream.end(); | |
| }); | |
| var inStream = fs.createReadStream('file.txt'); | |
| inStream.pipe(outStream); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment