顺序有问题
yancongwen opened this issue · comments
Promise.all = function(arr) {
if(!Array.isArray(arr)) {
throw new Error('参数必须是数组')
}
return new Promise((resolve, reject) => {
const list = []
arr.forEach(item => {
this.resolve(item).then((value) => {
list.push(value)
if(list.length === arr.length) {
resolve(list)
}
}, (err)=> {
reject(err)
})
})
})
}
Originally posted by @learnRy in #23 (comment)