Promise.all的简单实现
Promise
.all = arr
=> {
let aResult
= [];
return new _Promise(function (resolve
, reject
) {
let i
= 0;
next();
function next() {
arr
[i
].then(function (res
) {
aResult
.push(res
);
i
++;
if (i
== arr
.length
) {
resolve(aResult
);
} else {
next();
}
})
}
})
};
转载请注明原文地址:https://ipadbbs.8miu.com/read-46227.html