Skip to content

Instantly share code, notes, and snippets.

@koyanloshe
Forked from kmoskwiak/readFileSync.js
Created January 24, 2021 09:13
Show Gist options
  • Save koyanloshe/42b9beda7d41e059555eb370239a3329 to your computer and use it in GitHub Desktop.
Save koyanloshe/42b9beda7d41e059555eb370239a3329 to your computer and use it in GitHub Desktop.
const CHUNK_SIZE = 10000000; // 10MB
const data = fs.readFileSync('./file');
for(let bytesRead = 0; bytesRead < data.length; bytesRead = bytesRead + CHUNK_SIZE) {
// do something with data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment