docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility for tracking and settling promises from a custom Promise implementation with metadata support.
You are building a task execution system that uses a custom Promise subclass with additional metadata tracking capabilities. The system needs to wait for multiple tasks to complete and collect their results, regardless of whether they succeed or fail.
Implement a trackAllPromises function that accepts an array of custom Promise instances and waits for all of them to settle. The function should:
The result format should be:
{ status: 'fulfilled', value: <resolved-value> }{ status: 'rejected', reason: <rejection-reason> }The function must work correctly with custom Promise subclasses that have additional properties or modified behavior, preserving the subclass semantics.
/**
* Tracks all promises to settlement, preserving custom Promise subclass behavior.
*
* @param {Array} promises - An array of promises (may include custom Promise subclasses)
* @returns {Promise} A promise that resolves with an array of settlement result objects
*/
function trackAllPromises(promises) {
// Implementation here
}
module.exports = { trackAllPromises };Provides spec-compliant Promise.allSettled implementation with support for Promise subclasses.