The following code takes a bunch of file paths, reads the files, then counts their words:
;(async () =>
const wordCounts = await Promise.all(
filePaths.map(
filePath => fs.promises.readFile(filePath, 'utf-8')
.then(fileText => nlp(fileText).wordCount())
)
)
})()
How to use async/await instead of that then at the end?