Promise.all = (iterators) => {
return new Promise((resolve, reject) => {
const len = iterators.length;
if(!iterators || len === 0){
resolve([]);
}else{
const result = [];
for(let i = 0;i < len;i ++){
Promise.resolve(iterators[i]).then(
(data) => {
result[i] = data;
if(i === len - 1){
resolve(result);
}
},
(err) => {
reject(err);
return;
}
)
}
}
})
}
08-27
1915
06-26
2812
12-11
509
02-27
788
10-21
1002
04-25
6648
11-14
559