mediumcodingjavascript~12 min
Implement a Simplified Promise.all
Objective: Compose promises manually, preserving order and propagating the first rejection.
Write `promiseAll(iterable)` that resolves with all results in input order, and rejects as soon as any input rejects.
- Accept any iterable of promises or plain values.
- Resolve with results in input order, regardless of completion order.
- Reject with the first rejection reason.
- An empty input resolves to [].
JavaScript
⌘/Ctrl + Enter to run tests · Esc then Tab leaves the editor
Output
> Nothing has run yet.
Interview follow-up questions
- How does Promise.allSettled differ and when would you use it?
- What happens to the other promises when one rejects?
- How would you add a concurrency limit?