Skip to content

Instantly share code, notes, and snippets.

@celsowhite
Created September 14, 2021 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save celsowhite/a3bda3a71147201b5d6a31c391e8d59b to your computer and use it in GitHub Desktop.
Save celsowhite/a3bda3a71147201b5d6a31c391e8d59b to your computer and use it in GitHub Desktop.
Example of using a map function to process async requests in parallel.
async function printFiles () {
const files = await getFilePaths();
await Promise.all(files.map(async (file) => {
const contents = await fs.readFile(file, 'utf8')
console.log(contents)
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment