Implement promiseAll(iterable), which behaves like Promise.all. It takes an iterable of values (promises, thenables or plain values) and returns a promise that:
const slow = new Promise((r) => setTimeout(() => r('slow'), 50));
const fast = Promise.resolve('fast');
await promiseAll([slow, fast, 42]); // ['slow', 'fast', 42] (input order, not finish order)
await promiseAll([]); // []
await promiseAll([fast, Promise.reject(new Error('x'))]); // rejects with Error('x')
await promiseAll(new Set([1, 2])); // [1, 2] (any iterable works)
Promise.all, Promise.allSettled, Promise.any or Promise.race. You may use new Promise, Promise.resolve and .then.then method) are adopted.[].TypeError (it does not throw synchronously).Spotted a mistake or a rights concern? Report an issue