08

Promise.all polyfill

20 min·senior·

Implement promiseAll(iterable) matching the spec essentials of Promise.all:

  • Resolves to an array of resolved values, in input order
  • Rejects on first rejection
  • Accepts non-promise values (treated as already-resolved)
  • Empty iterable resolves immediately to []
expected time · O(n)
expected space · O(n)
4 lines
⏵ run · no run yet · ctrl+enter