Implement Promise.allSettled
Implement promiseAllSettled(promises), which behaves like Promise.allSettled for an array, without calling it. Promise.all, allSettled, race and any are switched off while it runs.
- Resolve once every input has settled, with one outcome object per input in input order:
{ status: "fulfilled", value }or{ status: "rejected", reason }. - Accept plain values beside promises.
- Never reject, whatever the inputs do.
- Resolve an empty input at once, with
[].
Everything runs on a virtual clock, so the grader sees exactly when the result settles.
Hints
Hint 1
The structure is Promise.all with the rejection handler changed: instead of rejecting the outer promise, record { status: "rejected", reason } at that index and count down like any other settlement.
Hint 2
Give then both handlers, and do the count-down in a second then so fulfilment and rejection share one path.
Asked at
Sign in to use the assistant — ask what the problem means, get a hint when you're stuck, or have your current work reviewed. Conversations save to your account.