将async.eachLimit转换为promise
我有这样的同步代码
async.eachLimit(teams, 1000, fetchTeamInfo, exit)
我需要将其转换为Promise(蓝鸟)
我认为会很好做出类似于:
Promise.method (teams, 1000, fetchTeamInfo) -> async.parallelLimit arr.map((a, i) -> -> iterator a, i, arr ), limit
但不确定是否正确
好吧,我看到你正在使用Promise.method
所以我假设蓝鸟 – 蓝鸟与Promise.map
已经支持你正在寻找与并发参数:
const fn = (teams, concurrency) => Promise.map(teams, fetchTeamInfo, {concurrency});
正如你所看到的,我们并没有在这里做太多 – 我们可以直接使用Promise.map
🙂
在CoffeeScript中,我认为它看起来像这样:
fn = (teams, concurrency) -> Promise.map teams, fetchTeamInfo, concurrency: concurrency
但是近3年来我还没有写过CoffeeScript。