or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-2/

Custom Promise Tracker

A utility for tracking and settling promises from a custom Promise implementation with metadata support.

Context

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.

Requirements

Implement a trackAllPromises function that accepts an array of custom Promise instances and waits for all of them to settle. The function should:

  1. Accept an array of promises (which may be instances of custom Promise subclasses)
  2. Wait for all promises to settle (fulfill or reject)
  3. Return a promise that resolves with an array of result objects
  4. Each result object should indicate the settlement status and outcome

The result format should be:

  • For fulfilled promises: { status: 'fulfilled', value: <resolved-value> }
  • For rejected promises: { 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.

Test Cases

  • Given an array with a mix of fulfilled and rejected custom promises, it returns all settlement results in order @test
  • Given an array containing both standard and custom Promise subclass instances, it handles all correctly @test
  • Given an empty array, it returns an empty array of results @test

Implementation

@generates

API

/**
 * 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 };

Dependencies { .dependencies }

promise.allsettled { .dependency }

Provides spec-compliant Promise.allSettled implementation with support for Promise subclasses.