function all (arr) {
return new Promise((resolve, reject) => {
let rtnArr = []
let count = 0
for (let i = 0; i < arr.length; i++) {
Promise.resolve(arr[i]).then(res => {
rtnArr[i] = res
count += 1
count == arr.length && resolve(rtnArr)
}, reject)
}
})
}
标签:count,arr,resolve,实现,res,简易,promise,let,rtnArr
From: https://www.cnblogs.com/772330747wh/p/17463044.html