Stage 1 Draft / November 7, 2025

Await Dictionary

27 Control Abstraction Objects

27.2 Promise Objects

27.2.4 Properties of the Promise Constructor

The Promise constructor:

  • has a [[Prototype]] internal slot whose value is %Function.prototype%.
  • has the following properties:

27.2.4.1 CreateKeyedPromiseCombinatorResultObject ( keys, values )

The abstract operation CreateKeyedPromiseCombinatorResultObject takes arguments keys (a List of property keys) and values (a List of ECMAScript language values) and returns an Object. It performs the following steps when called:

  1. Assert: The number of elements in keys is the same as the number of elements in values.
  2. Let obj be OrdinaryObjectCreate(null).
  3. For each integer i such that 0 ≤ i < the number of elements in keys, in ascending order, do
    1. Perform ! CreateDataPropertyOrThrow(obj, keys[i], values[i]).
  4. Return obj.

27.2.4.2 Promise.allKeyed ( promises )

This method performs the following steps when called:

  1. Let C be the this value.
  2. Let promiseCapability be ? NewPromiseCapability(C).
  3. Let promiseResolve be Completion(GetPromiseResolve(C)).
  4. IfAbruptRejectPromise(promiseResolve, promiseCapability).
  5. If promises is not an Object, then
    1. Let error be a newly created TypeError object.
    2. Perform ? Call(promiseCapability.[[Reject]], undefined, « error »).
    3. Return promiseCapability.[[Promise]].
  6. Let result be Completion(PerformPromiseAllKeyed(promises, C, promiseCapability, promiseResolve)).
  7. IfAbruptRejectPromise(result, promiseCapability).
  8. Return promiseCapability.[[Promise]].
Note

This function requires its this value to be a constructor function that supports the parameter conventions of the Promise constructor.

27.2.4.2.1 PerformPromiseAllKeyed ( promises, constructor, resultCapability, promiseResolve )

The abstract operation PerformPromiseAllKeyed takes arguments promises (an Object), constructor (a constructor), resultCapability (a PromiseCapability Record), and promiseResolve (a function object) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. Let allKeys be ? promises.[[OwnPropertyKeys]]().
  2. Let keys be a new empty List.
  3. Let values be a new empty List.
  4. Let remainingElementsCount be the Record { [[Value]]: 1 }.
  5. Let index be 0.
  6. For each element key of allKeys, do
    1. Let desc be ? promises.[[GetOwnProperty]](key).
    2. If desc is not undefined and desc.[[Enumerable]] is true, then
      1. Let value be ? Get(promises, key).
      2. Append key to keys.
      3. Append undefined to values.
      4. Let nextPromise be ? Call(promiseResolve, constructor, « value »).
      5. Let steps be the algorithm steps defined in Promise.allKeyed Resolve Element Functions.
      6. Let length be the number of non-optional parameters of the function definition in Promise.allKeyed Resolve Element Functions.
      7. Let onFulfilled be CreateBuiltinFunction(steps, length, "", « [[AlreadyCalled]], [[Index]], [[Keys]], [[Values]], [[Capability]], [[RemainingElements]] »).
      8. Set onFulfilled.[[AlreadyCalled]] to false.
      9. Set onFulfilled.[[Index]] to index.
      10. Set onFulfilled.[[Keys]] to keys.
      11. Set onFulfilled.[[Values]] to values.
      12. Set onFulfilled.[[Capability]] to resultCapability.
      13. Set onFulfilled.[[RemainingElements]] to remainingElementsCount.
      14. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] + 1.
      15. Perform ? Invoke(nextPromise, "then", « onFulfilled, resultCapability.[[Reject]] »).
      16. Set index to index + 1.
  7. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
  8. If remainingElementsCount.[[Value]] = 0, then
    1. NOTE: This can happen even if keys was non-empty if an ill-behaved thenable synchronously invoked the callback passed to its "then" method.
    2. Let result be CreateKeyedPromiseCombinatorResultObject(keys, values).
    3. Perform ? Call(resultCapability.[[Resolve]], undefined, « result »).
  9. Return resultCapability.[[Promise]].

27.2.4.2.2 Promise.allKeyed Resolve Element Functions

A Promise.all resolve element function is an anonymous built-in function

When a Promise.allKeyed resolve element function is called with argument x, the following steps are taken:

  1. Let F be the active function object.
  2. If F.[[AlreadyCalled]] is true, return undefined.
  3. Set F.[[AlreadyCalled]] to true.
  4. Let index be F.[[Index]].
  5. Let keys be F.[[Keys]].
  6. Let values be F.[[Values]].
  7. Let promiseCapability be F.[[Capability]].
  8. Let remainingElementsCount be F.[[RemainingElements]].
  9. Set values[index] to x.
  10. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
  11. If remainingElementsCount.[[Value]] = 0, then
    1. Let result be CreateKeyedPromiseCombinatorResultObject(keys, values).
    2. Return ? Call(promiseCapability.[[Resolve]], undefined, « result »).
  12. Return undefined.

27.2.4.3 Promise.allSettledKeyed ( promises )

This method performs the following steps when called:

  1. Let C be the this value.
  2. Let promiseCapability be ? NewPromiseCapability(C).
  3. Let promiseResolve be Completion(GetPromiseResolve(C)).
  4. IfAbruptRejectPromise(promiseResolve, promiseCapability).
  5. If promises is not an Object, then
    1. Let error be a newly created TypeError object.
    2. Perform ? Call(promiseCapability.[[Reject]], undefined, « error »).
    3. Return promiseCapability.[[Promise]].
  6. Let result be Completion(PerformPromiseAllSettledKeyed(promises, C, promiseCapability, promiseResolve)).
  7. IfAbruptRejectPromise(result, promiseCapability).
  8. Return promiseCapability.[[Promise]].
Note

This function requires its this value to be a constructor function that supports the parameter conventions of the Promise constructor.

27.2.4.3.1 PerformPromiseAllSettledKeyed ( promises, constructor, resultCapability, promiseResolve )

The abstract operation PerformPromiseAllSettledKeyed takes arguments promises (an Object), constructor (a constructor), resultCapability (a PromiseCapability Record), and promiseResolve (a function object) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. Let allKeys be ? promises.[[OwnPropertyKeys]]().
  2. Let keys be a new empty List.
  3. Let values be a new empty List.
  4. Let remainingElementsCount be the Record { [[Value]]: 1 }.
  5. Let index be 0.
  6. For each element key of allKeys, do
    1. Let desc be ? promises.[[GetOwnProperty]](key).
    2. If desc is not undefined and desc.[[Enumerable]] is true, then
      1. Let value be ? Get(promises, key).
      2. Append key to keys.
      3. Append undefined to values.
      4. Let nextPromise be ? Call(promiseResolve, constructor, « value »).
      5. Let stepsFulfilled be the algorithm steps defined in Promise.allSettledKeyed Resolve Element Functions.
      6. Let lengthFulfilled be the number of non-optional parameters of the function definition in Promise.allSettledKeyed Resolve Element Functions.
      7. Let onFulfilled be CreateBuiltinFunction(stepsFulfilled, lengthFulfilled, "", « [[AlreadyCalled]], [[Index]], [[Keys]], [[Values]], [[Capability]], [[RemainingElements]] »).
      8. Let alreadyCalled be the Record { [[Value]]: false }.
      9. Set onFulfilled.[[AlreadyCalled]] to alreadyCalled.
      10. Set onFulfilled.[[Index]] to index.
      11. Set onFulfilled.[[Keys]] to keys.
      12. Set onFulfilled.[[Values]] to values.
      13. Set onFulfilled.[[Capability]] to resultCapability.
      14. Set onFulfilled.[[RemainingElements]] to remainingElementsCount.
      15. Let stepsRejected be the algorithm steps defined in Promise.allSettledKeyed Reject Element Functions.
      16. Let lengthRejected be the number of non-optional parameters of the function definition in Promise.allSettledKeyed Reject Element Functions.
      17. Let onRejected be CreateBuiltinFunction(stepsRejected, lengthRejected, "", « [[AlreadyCalled]], [[Index]], [[Keys]], [[Values]], [[Capability]], [[RemainingElements]] »).
      18. Set onRejected.[[AlreadyCalled]] to alreadyCalled.
      19. Set onRejected.[[Index]] to index.
      20. Set onRejected.[[Keys]] to keys.
      21. Set onRejected.[[Values]] to values.
      22. Set onRejected.[[Capability]] to resultCapability.
      23. Set onRejected.[[RemainingElements]] to remainingElementsCount.
      24. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] + 1.
      25. Perform ? Invoke(nextPromise, "then", « onFulfilled, onRejected »).
      26. Set index to index + 1.
  7. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
  8. If remainingElementsCount.[[Value]] = 0, then
    1. NOTE: This can happen even if keys was non-empty if an ill-behaved thenable synchronously invoked the callback passed to its "then" method.
    2. Let result be CreateKeyedPromiseCombinatorResultObject(keys, values).
    3. Perform ? Call(resultCapability.[[Resolve]], undefined, « result »).
  9. Return resultCapability.[[Promise]].

27.2.4.3.2 Promise.allSettledKeyed Resolve Element Functions

A Promise.allSettledKeyed resolve element function is an anonymous built-in function that is used to resolve a specific Promise.allSettledKeyed element. Each Promise.allSettledKeyed resolve element function has [[Index]], [[Keys]], [[Values]], [[Capability]], [[RemainingElements]], and [[AlreadyCalled]] internal slots.

When a Promise.allSettledKeyed resolve element function is called with argument x, the following steps are taken:

  1. Let F be the active function object.
  2. Let alreadyCalled be F.[[AlreadyCalled]].
  3. If alreadyCalled.[[Value]] is true, return undefined.
  4. Set alreadyCalled.[[Value]] to true.
  5. Let index be F.[[Index]].
  6. Let keys be F.[[Keys]].
  7. Let values be F.[[Values]].
  8. Let promiseCapability be F.[[Capability]].
  9. Let remainingElementsCount be F.[[RemainingElements]].
  10. Let obj be OrdinaryObjectCreate(%Object.prototype%).
  11. Perform ! CreateDataPropertyOrThrow(obj, "status", "fulfilled").
  12. Perform ! CreateDataPropertyOrThrow(obj, "value", x).
  13. Set values[index] to obj.
  14. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
  15. If remainingElementsCount.[[Value]] = 0, then
    1. Let result be CreateKeyedPromiseCombinatorResultObject(keys, values).
    2. Return ? Call(promiseCapability.[[Resolve]], undefined, « result »).
  16. Return undefined.

The "length" property of a Promise.allSettledKeyed resolve element function is 1𝔽.

27.2.4.3.3 Promise.allSettledKeyed Reject Element Functions

A Promise.allSettledKeyed reject element function is an anonymous built-in function that is used to reject a specific Promise.allSettledKeyed element. Each Promise.allSettledKeyed reject element function has [[Index]], [[Keys]], [[Values]], [[Capability]], [[RemainingElements]], and [[AlreadyCalled]] internal slots.

When a Promise.allSettledKeyed reject element function is called with argument x, the following steps are taken:

  1. Let F be the active function object.
  2. Let alreadyCalled be F.[[AlreadyCalled]].
  3. If alreadyCalled.[[Value]] is true, return undefined.
  4. Set alreadyCalled.[[Value]] to true.
  5. Let index be F.[[Index]].
  6. Let keys be F.[[Keys]].
  7. Let values be F.[[Values]].
  8. Let promiseCapability be F.[[Capability]].
  9. Let remainingElementsCount be F.[[RemainingElements]].
  10. Let obj be OrdinaryObjectCreate(%Object.prototype%).
  11. Perform ! CreateDataPropertyOrThrow(obj, "status", "rejected").
  12. Perform ! CreateDataPropertyOrThrow(obj, "reason", x).
  13. Set values[index] to obj.
  14. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
  15. If remainingElementsCount.[[Value]] = 0, then
    1. Let result be CreateKeyedPromiseCombinatorResultObject(keys, values).
    2. Return ? Call(promiseCapability.[[Resolve]], undefined, « result »).
  16. Return undefined.

The "length" property of a Promise.allSettledKeyed reject element function is 1𝔽.

Copyright & Software License

Software License

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.