Promise.all(iterable) Method returns a Promise example , This instance is in iterable All of the promise
all “ complete (resolved)” Or parameter does not contain promise Callback complete when (resolve); If the promise
There was a failure (rejected), The instance callback failed (reject), The reason for failure is the first failure promise Results .
// Handwriting Promise.all() Promise.property.all = function (iterators) { const
promises = Array.from(iterators); const len = promises.length; let count = 0;
let resultList = []; return new Promise((resolve,reject)=>{
promises.forEach((p,index) =>{ Promise.resolve(p) .then((result)=>{ count++;
resultList[index] = result; if(count === len){ resolve(resultList); } })
.catch(e=>{ reject(e); }) }) }) }
Technology