标签:final dex return bsp script finish -- finally strong
function limitRequest(tasks,n){ return new Promise((resolve,reject) => { let index = 0//当前第几个执行 let start = 0//当前执行几个 let finish = 0//总共执行完几个 let arr = []//执行完结果 let run = () => { if(finish == tasks.length){ resolve(arr) return } while(start <= n && index < tasks.length){ start++ let cur = index tasks[cur]().then((res) => { arr[cur] = res }).catch((err) => { arr[cur] = err }).finally(()=>{ index++ finish++ start-- run() }) } } run() }) }
可能有些问题,如发现问题,望指正!!!
标签:final dex return bsp script finish -- finally strong
原文地址:https://www.cnblogs.com/zhenjianyu/p/13423860.html