【发布时间】:2018-08-29 19:25:48
【问题描述】:
有没有办法使用新的“async”javascript 关键字来替换 async 模块中的 async.map?基本上我想尽可能避免使用异步模块。例如,一次读取多个文件,然后在读取完所有文件后执行操作。
【问题讨论】:
-
使用
Promise.all()在 N 个并行运行的操作全部完成时获得通知。还有 Bluebird Promise 库,它具有Promise.map()和Promise.promisifyAll()等有用的功能。见Are there still reasons to use promise libraries now that we have ES6。
标签: javascript node.js asynchronous ecmascript-6 promise