Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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
2+7 =