J
Size: a a a
J
V
М
мм
мм
мм
A
ТВ
мм
в
DV
мм
DV
АМ
АМ
мой код: const promise1 = Promise.resolve(3);
const promise2 = new Promise((resolve, reject) => setTimeout(reject, 100, 'foo'));
const promises = [promise1, promise2, promise2, promise2, promise2, promise2, promise2];
async function promiseAllWithThreshold(arr, treshhold) {
let neg = 0;
return Promise.allSettled(arr).then((results) => results.forEach((result) => {
if (result.status === 'rejected') {
neg++;
console.log('ok')
}
if (neg > treshhold) {
throw new Error('Fail')
}
},
)).catch(e => console.log(e));
}
console.log(promiseAllWithThreshold(promises, 3))АМ
АМ
Г
ED
npm install -g npm@7.17.0 to update!