MediumPythonJavaScriptTypeScript

Implement Promise.all

AsyncFunctions

Re-implement the semantics of Promise.all as a function promiseAll.
Don't delegate to native Promise.all — write the orchestration yourself
using a single new Promise and the .then callbacks of each input.

Requirements

  • Resolves with an array of results in input order, regardless of which

promise settled first.

  • Rejects with the first encountered rejection reason.
  • An empty input must resolve with [].

solve(values, options) is provided to drive your implementation against
test inputs and return a JSON-friendly outcome.

Sample tests

Test #1Rejects with the first failing reason
Input: [["a","b","c"],{"rejectAt":1}]
Output: {"reason":"err:b","status":"rejected"}
Test #2Empty input resolves with empty array
Input: [[],{}]
Output: {"status":"fulfilled","values":[]}
Test #3All resolve in order
Input: [[1,2,3],{}]
Output: {"status":"fulfilled","values":[1,2,3]}
Test #4Larger input
Input: [[10,20,30,40],{}]
Output: {"status":"fulfilled","values":[10,20,30,40]}
Test #5Rejection at index 0
Input: [["x","y","z"],{"rejectAt":0}]
Output: {"reason":"err:x","status":"rejected"}