?
u
m
/
p
1-9
0
`
An interface is a set of
The iterable interface includes the property described in
Property | Value | Requirements |
---|---|---|
%Symbol.iterator%
|
a function that returns an |
The returned object must conform to the |
An object that implements the iterator interface must include the property in
Property | Value | Requirements |
---|---|---|
|
a function that returns an |
The returned object must conform to the next method of an next method of that object should also return an |
Arguments may be passed to the next
function but their interpretation and validity is dependent upon the target iterator. The for-of statement and other common users of iterators do not pass any arguments, so iterator objects that expect to be used in such a manner must be prepared to deal with being called with no arguments.
Property | Value | Requirements |
---|---|---|
|
a function that returns an |
The returned object must conform to the next method calls to the return method. However, this requirement is not enforced.
|
|
a function that returns an |
The returned object must conform to the throw the value passed as the argument. If the method does not throw , the returned |
Typically callers of these methods should check for their existence before invoking them. Certain ECMAScript language features including for
-of
, yield*
, and array destructuring call these methods after performing an existence check. Most ECMAScript library functions that accept
The async iterable interface includes the properties described in
Property | Value | Requirements |
---|---|---|
%Symbol.asyncIterator% |
a function that returns an |
The returned object must conform to the |
An object that implements the async iterator interface must include the properties in
Property | Value | Requirements |
---|---|---|
a function that returns a promise for an |
The returned promise, when fulfilled, must fulfill with an object that conforms to the Additionally, the |
Arguments may be passed to the next
function but their interpretation and validity is dependent upon the target async iterator. The for
-await
-of
statement and other common users of async iterators do not pass any arguments, so async iterator objects that expect to be used in such a manner must be prepared to deal with being called with no arguments.
Property | Value | Requirements |
---|---|---|
a function that returns a promise for an |
The returned promise, when fulfilled, must fulfill with an object that conforms to the Additionally, the |
|
a function that returns a promise for an |
The returned promise, when fulfilled, must fulfill with an object that conforms to the If the returned promise is fulfilled, the |
Typically callers of these methods should check for their existence before invoking them. Certain ECMAScript language features including for
-await
-of
and yield*
call these methods after performing an existence check.
The IteratorResult interface includes the properties listed in
Property | Value | Requirements |
---|---|---|
|
a Boolean |
This is the result status of an next method call. If the end of the |
|
an |
If done is |
An Iterator Helper object is an
The %IteratorHelperPrototype% object:
The initial value of the
This property has the attributes { [[Writable]]:
The Iterator
This function performs the following steps when called:
The
The %WrapForValidIteratorPrototype% object:
The initial value of Iterator.prototype is the
This property has the attributes { [[Writable]]:
The Iterator prototype object:
All objects defined in this specification that implement the
The following expression is one way that ECMAScript code can access the %Iterator.prototype% object:
Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))
Iterator.prototype.constructor
is an
The value of the [[Get]] attribute is a built-in function that requires no arguments. It performs the following steps when called:
The value of the [[Set]] attribute is a built-in function that takes an argument v. It performs the following steps when called:
Unlike the
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This function performs the following steps when called:
The value of the
Iterator.prototype[%Symbol.toStringTag%]
is an
The value of the [[Get]] attribute is a built-in function that requires no arguments. It performs the following steps when called:
The value of the [[Set]] attribute is a built-in function that takes an argument v. It performs the following steps when called:
Unlike the
The %AsyncIteratorPrototype% object:
All objects defined in this specification that implement the
This function performs the following steps when called:
The value of the
An Async-from-Sync Iterator object is an
The abstract operation CreateAsyncFromSyncIterator takes argument syncIteratorRecord (an
The %AsyncFromSyncIteratorPrototype% object:
throw
method, close it to give it a chance to clean up before we reject the capability.throw
method.Async-from-Sync
Internal Slot | Type | Description |
---|---|---|
[[SyncIteratorRecord]] |
an |
Represents the original synchronous |
The abstract operation AsyncFromSyncIteratorContinuation takes arguments result (an Object), promiseCapability (a
A Promise is an object that is used as a placeholder for the eventual results of a deferred (and possibly asynchronous) computation.
Any Promise is in one of three mutually exclusive states: fulfilled, rejected, and pending:
p
is fulfilled if p.then(f, r)
will immediately enqueue a f
.
p
is rejected if p.then(f, r)
will immediately enqueue a r
.
A promise is said to be settled if it is not pending, i.e. if it is either fulfilled or rejected.
A promise is resolved if it is settled or if it has been “locked in” to match the state of another promise. Attempting to resolve or reject a resolved promise has no effect. A promise is unresolved if it is not resolved. An unresolved promise is always in the pending state. A resolved promise may be pending, fulfilled or rejected.
A PromiseCapability Record is a
PromiseCapability Records have the fields listed in
Field Name | Value | Meaning |
---|---|---|
[[Promise]] | an Object | An object that is usable as a promise. |
[[Resolve]] |
a |
The function that is used to resolve the given promise. |
[[Reject]] |
a |
The function that is used to reject the given promise. |
IfAbruptRejectPromise is a shorthand for a sequence of algorithm steps that use a
means the same thing as:
A PromiseReaction Record is a
PromiseReaction Records have the fields listed in
Field Name | Value | Meaning |
---|---|---|
[[Capability]] |
a |
The capabilities of the promise for which this record provides a reaction handler. |
[[Type]] |
|
The [[Type]] is used when [[Handler]] is |
[[Handler]] |
a |
The function that should be applied to the incoming value, and whose return value will govern what happens to the derived promise. If [[Handler]] is |
The abstract operation CreateResolvingFunctions takes argument promise (a Promise) and returns a
A promise reject function is an anonymous built-in function that has [[Promise]] and [[AlreadyResolved]] internal slots.
When a promise reject function is called with argument reason, the following steps are taken:
The
A promise resolve function is an anonymous built-in function that has [[Promise]] and [[AlreadyResolved]] internal slots.
When a promise resolve function is called with argument resolution, the following steps are taken:
The
The abstract operation FulfillPromise takes arguments promise (a Promise) and value (an
The abstract operation NewPromiseCapability takes argument C (an resolve
and reject
functions. The promise plus the resolve
and reject
functions are used to initialize a new
This abstract operation supports Promise subclassing, as it is generic on any
The abstract operation IsPromise takes argument x (an
The abstract operation RejectPromise takes arguments promise (a Promise) and reason (an
The abstract operation TriggerPromiseReactions takes arguments reactions (a
The
The default implementation of HostPromiseRejectionTracker is to return
HostPromiseRejectionTracker is called in two scenarios:
A typical implementation of HostPromiseRejectionTracker might try to notify developers of unhandled rejections, while also being careful to notify them if such previous notifications are later invalidated by new handlers being attached.
If operation is
The abstract operation NewPromiseReactionJob takes arguments reaction (a
The abstract operation NewPromiseResolveThenableJob takes arguments promiseToResolve (a Promise), thenable (an Object), and then (a
The Promise
extends
clause of a class definition. Subclass super
call to the Promise Promise
and Promise.prototype
built-in methods.This function performs the following steps when called:
The executor argument must be a
The resolve function that is passed to an executor function accepts a single argument. The executor code may eventually call the resolve function to indicate that it wishes to resolve the associated Promise. The argument passed to the resolve function represents the eventual value of the deferred action and can be either the actual fulfillment value or another promise which will provide the value if it is fulfilled.
The reject function that is passed to an executor function accepts a single argument. The executor code may eventually call the reject function to indicate that the associated Promise is rejected and will never be fulfilled. The argument passed to the reject function is used as the rejection value of the promise. Typically it will be an Error object.
The resolve and reject functions passed to an executor function by the Promise
The Promise
This function returns a new promise which is fulfilled with an array of fulfillment values for the passed promises, or rejects with the reason of the first passed promise that rejects. It resolves all elements of the passed
This function requires its
The abstract operation GetPromiseResolve takes argument promiseConstructor (a
The abstract operation PerformPromiseAll takes arguments iteratorRecord (an
Promise.all
Resolve Element FunctionsPromise.all
Resolve Element FunctionsPromise.all
Resolve Element FunctionsA Promise.all
resolve element function is an anonymous built-in function that is used to resolve a specific Promise.all
element. Each Promise.all
resolve element function has [[Index]], [[Values]], [[Capability]], [[RemainingElements]], and [[AlreadyCalled]] internal slots.
When a Promise.all
resolve element function is called with argument x, the following steps are taken:
The Promise.all
resolve element function is
This function returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected. It resolves all elements of the passed
This function requires its
The abstract operation PerformPromiseAllSettled takes arguments iteratorRecord (an
Promise.allSettled
Resolve Element FunctionsPromise.allSettled
Resolve Element FunctionsPromise.allSettled
Reject Element FunctionsPromise.allSettled
Reject Element FunctionsPromise.allSettled
Resolve Element FunctionsA Promise.allSettled
resolve element function is an anonymous built-in function that is used to resolve a specific Promise.allSettled
element. Each Promise.allSettled
resolve element function has [[Index]], [[Values]], [[Capability]], [[RemainingElements]], and [[AlreadyCalled]] internal slots.
When a Promise.allSettled
resolve element function is called with argument x, the following steps are taken:
The Promise.allSettled
resolve element function is
Promise.allSettled
Reject Element FunctionsA Promise.allSettled
reject element function is an anonymous built-in function that is used to reject a specific Promise.allSettled
element. Each Promise.allSettled
reject element function has [[Index]], [[Values]], [[Capability]], [[RemainingElements]], and [[AlreadyCalled]] internal slots.
When a Promise.allSettled
reject element function is called with argument x, the following steps are taken:
The Promise.allSettled
reject element function is
This function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError
holding the rejection reasons if all of the given promises are rejected. It resolves all elements of the passed
This function requires its Promise
The abstract operation PerformPromiseAny takes arguments iteratorRecord (an
Promise.any
Reject Element FunctionsPromise.any
Reject Element FunctionsPromise.any
Reject Element FunctionsA Promise.any
reject element function is an anonymous built-in function that is used to reject a specific Promise.any
element. Each Promise.any
reject element function has [[Index]], [[Errors]], [[Capability]], [[RemainingElements]], and [[AlreadyCalled]] internal slots.
When a Promise.any
reject element function is called with argument x, the following steps are taken:
The Promise.any
reject element function is
The initial value of Promise.prototype
is the
This property has the attributes { [[Writable]]:
This function returns a new promise which is settled in the same way as the first passed promise to settle. It resolves all elements of the passed iterable to promises as it runs this algorithm.