1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Promise.any = function (promises) { const result = []; return new Promise((resolve, reject) => { promises.forEach((item, index) => { item .then((res) => resolve(res)) .catch((error) => { result.push(error); if (index === pro mises.length - 1) { reject(result); } }); }); }); };
|