Skip to content

Instantly share code, notes, and snippets.

@koyanloshe
Forked from kmoskwiak/createReadStream.js
Created January 24, 2021 09:13
Show Gist options
  • Save koyanloshe/96435ee42510a98194a4689ee12a0c76 to your computer and use it in GitHub Desktop.
Save koyanloshe/96435ee42510a98194a4689ee12a0c76 to your computer and use it in GitHub Desktop.
const CHUNK_SIZE = 10000000; // 10MB
async function start() {
const stream = fs.createReadStream('./file', { highWaterMark: CHUNK_SIZE });
for await(const data of stream) {
// do something with data
}
}
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment