const fs = require('fs'); // Create a readable stream in chunks inside buffer // HighWaterMark => the size of a chunck let readable = fs.createReadStream(_dirname + '/path.txt', { encoding: 'utf8', highWaterMark: 32 * 1024 }); // Writable stream let writable = fs.createWriteStream(_dirname + '/pathCopy.txt'); // Stream is an event emitter readable.on('data', chunk => { writable.write(chunk); })
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter