Skip to content

Instantly share code, notes, and snippets.

@baptistemanson
Created June 29, 2018 07:16
Show Gist options
  • Save baptistemanson/bd8b5e1fccc44b0dccb51ffeca249710 to your computer and use it in GitHub Desktop.
Save baptistemanson/bd8b5e1fccc44b0dccb51ffeca249710 to your computer and use it in GitHub Desktop.
Node can use several threads, even if you only write JS
const fs = require("fs");
const util = require("util");
const readFile = util.promisify(fs.readFile);
async function long() {
const content = await readFile("./dummy1000000.csv", "utf-8");
content.split(/\n/);
}
const arr = [];
for (let i = 0; i < 10; i++) {
arr.push(long());
}
Promise.all(arr).then(() => console.log("wicked parallel dang"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment