Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Read (and write) file by chunks

  • createReadStream
  • createWriteStream
  • on
  • write
const fs = require('fs');

const readStream = fs.createReadStream('README', 'utf8'); // inherits from events
const writeStream = fs.createWriteStream('README.txt');
readStream.on('data', (chunk) => {
    if (chunk) {
        writeStream.write(chunk);
    }
});