Sobes.tech
Junior — Senior

Custom polyfill for Promise.all

livecode

Task condition

Write a function promiseAll that mimics the behavior of the built-in Promise.all. The function should accept an array of promises and return a new promise that will be fulfilled successfully only when all the passed promises are fulfilled, and in case any of them is rejected – it should immediately reject with the same reason. The order of results in the array should correspond to the order of the input array elements.

function promiseAll(tasks: Promise<any>[]): Promise<any[]> {
  // your code here
}