共计 347 个字符,预计需要花费 1 分钟才能阅读完成。
Promise.all=(proArr) =>{return new Promise((resolve, reject) => {let retsult = []
let count = 0
for (let i = 0; i < proArr.length; i++) {proArr[i].then(data => {retsult[i]=data
if(++count===proArr.length){resolve(retsult)
}
}, reject)
}
})
}
Promise.race=(promiseAry)=> {return new Promise((resolve, reject) => {for (let i = 0; i < promiseAry.length; i++) {promiseAry[i].then(resolve, reject)
}
})
}
正文完
发表至: javascript
2020-07-14