or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-5/

Promise Result Aggregator

A utility that processes multiple asynchronous operations and provides detailed reporting of their outcomes, handling various input types gracefully.

Requirements

Build a function that accepts an array of async operations (promises and/or plain values) and returns a promise that resolves to an array of result objects.

Each result object must contain:

  • A status field: either 'fulfilled' or 'rejected'
  • For fulfilled operations: a value field with the result
  • For rejected operations: a reason field with the error

Important behavior:

  • The returned promise must always resolve (never reject)
  • Results must maintain the same order as the input array
  • Plain (non-promise) values should be treated as fulfilled operations
  • Empty arrays should return empty result arrays

Test Cases

  • When given an array with all fulfilled promises, returns an array of objects with status 'fulfilled' and respective values @test
  • When given an array with all rejected promises, returns an array of objects with status 'rejected' and respective reasons @test
  • When given an array mixing fulfilled promises, rejected promises, and plain values, returns correctly formatted results for each @test
  • When given an empty array, returns an empty array @test

Implementation

@generates

API

/**
 * Processes multiple async operations and returns their results
 * @param {Iterable} operations - Collection of promises and/or values
 * @returns {Promise<Array>} Promise resolving to array of result objects
 */
function aggregateResults(operations) {
  // Implementation here
}

module.exports = { aggregateResults };

Dependencies { .dependencies }

promise.allsettled { .dependency }

Provides promise settlement tracking functionality.