Skip to content

Instantly share code, notes, and snippets.

@kmoskwiak
Created December 7, 2020 07:38
Show Gist options
  • Save kmoskwiak/3d6cfab3eb39dd63e026b140b23a1a85 to your computer and use it in GitHub Desktop.
Save kmoskwiak/3d6cfab3eb39dd63e026b140b23a1a85 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