34. implement `Promise.any()`

JavaScript
Is this helpful ?

medium  - accepted / - tried

Promise.any() takes an iterable of Promise objects and, as soon as one of the promises in the iterable fulfils, returns a single promise that resolves with the value from that promise

Can you implement a any() to work the same as Promise.any()?

note

AggregateError is not supported in Chrome yet, but you can still use it in your code since we will add the Class into your code. Do something like following:

new AggregateError(
  'No Promise in Promise.any was resolved', 
  errors
)

Let's try to solve this problem within 10 mintues.

Discuss(56)