Created
September 14, 2021 16:59
-
-
Save celsowhite/a3bda3a71147201b5d6a31c391e8d59b to your computer and use it in GitHub Desktop.
Example of using a map function to process async requests in parallel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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