For the first one, what about error handling? You have to handle errors by both the read and write stream, and also most people will want a callback when everything is done, so you have to handle that event, too.
Re:Node v8.5.0
by VeejayRampay on Wednesday September 13, 2017 @11:54AM
(#15239501)
Are streams really considered "slow"? Would your second example be faster in practice for most files?
fs.createReadStream('file.txt').pipe(fs.createWriteStream('new-file.txt'))
Streams are too slow you say?
fs.writeFileSync('new-file.txt', fs.readFileSync('file.txt'))
I've never had a problem with no explicit copy, but I am very happy it has been added...