docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a utility that processes collections of asynchronous operations and provides detailed settlement information. The utility should handle various input types including promises, regular values, and promise-like objects (thenables).
Your implementation should:
The utility must correctly process:
then method (thenables)For each input item, return an object with:
/**
* Processes a collection of values/promises and returns settlement information
* @param {Iterable} items - Collection of promises, thenables, or values
* @returns {Promise<Array>} Promise resolving to array of settlement objects
*/
function processSettlements(items) {
// Implementation here
}
module.exports = { processSettlements };Promise.resolve(42), Promise.reject(new Error('failed')), and the plain value 'direct', it returns an array with three objects: {status: 'fulfilled', value: 42}, {status: 'rejected', reason: Error('failed')}, and {status: 'fulfilled', value: 'direct'} @test{then: (resolve) => resolve('thenable-value')}, it correctly resolves the thenable and returns {status: 'fulfilled', value: 'thenable-value'} in the results @test[], it returns an empty array [] @testProvides promise settlement tracking with spec-compliant handling of various input types.