Sobes.tech
Junior — Senior

Independent implementation of the Promise.all function

livecode

Task condition

It is necessary to write a function that mimics the behavior of the built-in Promise.all. The function should accept an array (or any iterable object) of promises and return a new promise that:

  • transitions to the fulfilled state when all the passed promises have successfully completed;
  • transitions to the rejected state immediately after any of the passed promises is rejected. The function must work correctly with already settled/rejected promises as well as with regular values, automatically converting them into promises. Implement it without referring to the original Promise.all.