Skip to content

Instantly share code, notes, and snippets.

@mmomtchev
Created July 9, 2020 13:33
Show Gist options
  • Save mmomtchev/329566e3b3a113bf12cb460b34989389 to your computer and use it in GitHub Desktop.
Save mmomtchev/329566e3b3a113bf12cb460b34989389 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const rs = fs.createReadStream('allCountries.txt');
const parseline = require('./parseline');
console.time(__filename);
let remainder = '';
rs.on('data', (buf) => {
const lines = (remainder + buf).split(/\r?\n/g);
remainder = lines.pop();
for (const line of lines) {
parseline(line);
}
});
rs.on('close', () => console.timeEnd(__filename));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment