以下代码接收一堆文件路径,读取这些文件,然后计算它们的单词数量:
;(async () =>
const wordCounts = await Promise.all(
filePaths.map(
filePath => fs.promises.readFile(filePath, 'utf-8')
.then(fileText => nlp(fileText).wordCount())
)
)
})()
如何使用async/await
代替在末尾使用then
?