Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

ts await foreach loop

async function printFiles () {
  const files = await getFilePaths();

  await Promise.all(files.map(async (file) => {
    const contents = await fs.readFile(file, 'utf8')
    console.log(contents)
  }));
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ts #await #foreach #loop
ADD COMMENT
Topic
Name
9+1 =