?
u
m
/
p
1-9
An interface is a set of
The Iterable interface includes the property described in
An object that implements the
Property | Value | Requirements |
---|---|---|
|
a function that returns an IteratorResult object |
The returned object must conform to the IteratorResult interface. If a previous call to the next method of an next method of that object should also return an IteratorResult object whose |
Arguments may be passed to the next
function but their interpretation and validity is dependent upon the target
Property | Value | Requirements |
---|---|---|
|
a function that returns an IteratorResult object |
The returned object must conform to the IteratorResult interface. Invoking this method notifies the next method calls to the return method. However, this requirement is not enforced.
|
|
a function that returns an IteratorResult object |
The returned object must conform to the IteratorResult interface. Invoking this method notifies the throw the value passed as the argument. If the method does not throw , the returned IteratorResult object will typically have a |
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 Iterable objects as arguments also conditionally call them.
The AsyncIterable interface includes the properties described in
Property | Value | Requirements |
---|---|---|
%Symbol.asyncIterator% |
a function that returns an AsyncIterator object | The returned object must conform to the AsyncIterator interface. |
An object that implements the AsyncIterator interface must include the properties in
Property | Value | Requirements |
---|---|---|
a function that returns a promise for an IteratorResult object |
The returned promise, when fulfilled, must fulfill with an object that conforms to the IteratorResult interface. If a previous call to the Additionally, the IteratorResult object that serves as a fulfillment value should have a |
Arguments may be passed to the next
function but their interpretation and validity is dependent upon the target AsyncIterator. The for
-await
-of
statement and other common users of AsyncIterators do not pass any arguments, so AsyncIterator 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 IteratorResult object |
The returned promise, when fulfilled, must fulfill with an object that conforms to the IteratorResult interface. Invoking this method notifies the AsyncIterator object that the caller does not intend to make any more Additionally, the IteratorResult object that serves as a fulfillment value should have a |
|
a function that returns a promise for an IteratorResult object |
The returned promise, when fulfilled, must fulfill with an object that conforms to the IteratorResult interface. Invoking this method notifies the AsyncIterator object that the caller has detected an error condition. The argument may be used to identify the error condition and typically will be an exception object. A typical response is to return a rejected promise which rejects with the value passed as the argument. If the returned promise is fulfilled, the IteratorResult fulfillment value will typically have a |
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 iterator next method call. If the end of the iterator was reached |
|
an |
If done 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
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 AsyncIterator interface also inherit from %AsyncIteratorPrototype%. ECMAScript code may also define objects that inherit from %AsyncIteratorPrototype%. The %AsyncIteratorPrototype% object provides a place where additional methods that are applicable to all async iterator objects may be added.
This function performs the following steps when called:
The value of the
An Async-from-Sync
The abstract operation CreateAsyncFromSyncIterator takes argument syncIteratorRecord (an
The %AsyncFromSyncIteratorPrototype% object:
Async-from-Sync
Internal Slot | Type | Description |
---|---|---|
[[SyncIteratorRecord]] |
an |
Represents the original synchronous iterator which is being adapted. |
The abstract operation AsyncFromSyncIteratorContinuation takes arguments result (an Object) and 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 iterable to promises as it runs this algorithm.
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 iterable to promises as it runs this algorithm.
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 iterable to promises as it runs this algorithm.
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.
If the iterable argument yields no values or if none of the promises yielded by iterable ever settle, then the pending promise returned by this method will never be settled.
This function expects its resolve
method.
The abstract operation PerformPromiseRace takes arguments iteratorRecord (an
This function returns a new promise rejected with the passed argument.
This function expects its
This function returns either a new promise resolved with the passed argument, or the argument itself if the argument is a promise produced by this
This function expects its
The abstract operation PromiseResolve takes arguments C (an Object) and x (an
When the try
method is called with argument callback, the following steps are taken:
This function expects its
This function returns an object with three properties: a new promise together with the resolve
and reject
functions associated with it.
Promise[%Symbol.species%]
is an
The value of the
Promise prototype methods normally use their
The Promise prototype object:
This method performs the following steps when called:
The initial value of Promise.prototype.constructor
is
This method performs the following steps when called:
This method performs the following steps when called:
The abstract operation PerformPromiseThen takes arguments promise (a Promise), onFulfilled (an
The initial value of the
This property has the attributes { [[Writable]]:
Promise instances are
Internal Slot | Type | Description |
---|---|---|
[[PromiseState]] |
|
Governs how a promise will react to incoming calls to its then method.
|
[[PromiseResult]] |
an |
The value with which the promise has been fulfilled or rejected, if any. Only meaningful if [[PromiseState]] is not |
[[PromiseFulfillReactions]] |
a |
|
[[PromiseRejectReactions]] |
a |
|
[[PromiseIsHandled]] | a Boolean | Indicates whether the promise has ever had a fulfillment or rejection handler; used in unhandled rejection tracking. |
GeneratorFunctions are functions that are usually created by evaluating
The GeneratorFunction
Function
.GeneratorFunction (…)
is equivalent to the object creation expression new GeneratorFunction (…)
with the same arguments.extends
clause of a class definition. Subclass super
call to the GeneratorFunction The last argument (if any) specifies the body (executable code) of a generator function; any preceding arguments specify formal parameters.
This function performs the following steps when called:
See NOTE for
The GeneratorFunction
The initial value of GeneratorFunction.prototype
is the
This property has the attributes { [[Writable]]:
The GeneratorFunction prototype object:
The initial value of GeneratorFunction.prototype.constructor
is
This property has the attributes { [[Writable]]:
The initial value of GeneratorFunction.prototype.prototype
is
This property has the attributes { [[Writable]]:
The initial value of the
This property has the attributes { [[Writable]]:
Every GeneratorFunction instance is an ECMAScript
Each GeneratorFunction instance has the following own properties:
The specification for the
The specification for the
Whenever a GeneratorFunction instance is created another
This property has the attributes { [[Writable]]:
Unlike Function instances, the object that is the value of a GeneratorFunction's
AsyncGeneratorFunctions are functions that are usually created by evaluating
The AsyncGeneratorFunction
Function
.AsyncGeneratorFunction (...)
is equivalent to the object creation expression new AsyncGeneratorFunction (...)
with the same arguments.extends
clause of a class definition. Subclass super
call to the AsyncGeneratorFunction The last argument (if any) specifies the body (executable code) of an async generator function; any preceding arguments specify formal parameters.
This function performs the following steps when called:
See NOTE for
The AsyncGeneratorFunction
The initial value of AsyncGeneratorFunction.prototype
is the
This property has the attributes { [[Writable]]:
The AsyncGeneratorFunction prototype object:
The initial value of AsyncGeneratorFunction.prototype.constructor
is
This property has the attributes { [[Writable]]:
The initial value of AsyncGeneratorFunction.prototype.prototype
is
This property has the attributes { [[Writable]]:
The initial value of the
This property has the attributes { [[Writable]]:
Every AsyncGeneratorFunction instance is an ECMAScript
Each AsyncGeneratorFunction instance has the following own properties:
The value of the
This property has the attributes { [[Writable]]:
The specification for the
Whenever an AsyncGeneratorFunction instance is created, another
This property has the attributes { [[Writable]]:
Unlike function instances, the object that is the value of an AsyncGeneratorFunction's
A Generator is created by calling a generator function and conforms to both the
Generator instances directly inherit properties from the initial value of the
The %GeneratorPrototype% object:
The initial value of .constructor
is
This property has the attributes { [[Writable]]:
This method performs the following steps when called:
This method performs the following steps when called:
The initial value of the
This property has the attributes { [[Writable]]:
Generator instances are initially created with the internal slots described in
Internal Slot | Type | Description |
---|---|---|
[[GeneratorState]] |
|
The current execution state of the generator. |
[[GeneratorContext]] |
an |
The |
[[GeneratorBrand]] |
a String or |
A brand used to distinguish different kinds of generators. The [[GeneratorBrand]] of generators declared by |
The abstract operation GeneratorStart takes arguments generator (a Generator) and generatorBody (a
The abstract operation GeneratorValidate takes arguments generator (an
The abstract operation GeneratorResume takes arguments generator (an
The abstract operation GeneratorResumeAbrupt takes arguments generator (an
The abstract operation GetGeneratorKind takes no arguments and returns
The abstract operation GeneratorYield takes argument iteratorResult (an Object that conforms to the IteratorResult interface) and returns either a
The abstract operation Yield takes argument value (an
The abstract operation CreateIteratorFromClosure takes arguments closure (an
An AsyncGenerator is created by calling an async generator function and conforms to both the AsyncIterator and AsyncIterable interfaces.
AsyncGenerator instances directly inherit properties from the initial value of the
The %AsyncGeneratorPrototype% object:
The initial value of .constructor
is
This property has the attributes { [[Writable]]:
The initial value of the
This property has the attributes { [[Writable]]:
AsyncGenerator instances are initially created with the internal slots described below:
Internal Slot | Type | Description |
---|---|---|
[[AsyncGeneratorState]] | The current execution state of the async generator. | |
[[AsyncGeneratorContext]] | an |
The |
[[AsyncGeneratorQueue]] | a |
|
[[GeneratorBrand]] | a String or |
A brand used to distinguish different kinds of async generators. The [[GeneratorBrand]] of async generators declared by |
An AsyncGeneratorRequest is a
They have the following fields:
Field Name | Value | Meaning |
---|---|---|
[[Completion]] | a |
The |
[[Capability]] | a |
The promise capabilities associated with this request. |
The abstract operation AsyncGeneratorStart takes arguments generator (an AsyncGenerator) and generatorBody (a
The abstract operation AsyncGeneratorValidate takes arguments generator (an
The abstract operation AsyncGeneratorEnqueue takes arguments generator (an AsyncGenerator), completion (a
The abstract operation AsyncGeneratorCompleteStep takes arguments generator (an AsyncGenerator), completion (a
The abstract operation AsyncGeneratorResume takes arguments generator (an AsyncGenerator) and completion (a
The abstract operation AsyncGeneratorUnwrapYieldResumption takes argument resumptionValue (a
The abstract operation AsyncGeneratorYield takes argument value (an
The abstract operation AsyncGeneratorAwaitReturn takes argument generator (an AsyncGenerator) and returns
The abstract operation AsyncGeneratorDrainQueue takes argument generator (an AsyncGenerator) and returns
The abstract operation CreateAsyncIteratorFromClosure takes arguments closure (an
AsyncFunctions are functions that are usually created by evaluating
The AsyncFunction
Function
.AsyncFunction(…)
is equivalent to the object creation expression new AsyncFunction(…)
with the same arguments.extends
clause of a class definition. Subclass super
call to the AsyncFunction The last argument (if any) specifies the body (executable code) of an async function. Any preceding arguments specify formal parameters.
This function performs the following steps when called:
The AsyncFunction
The initial value of AsyncFunction.prototype
is the
This property has the attributes { [[Writable]]:
The AsyncFunction prototype object:
The initial value of AsyncFunction.prototype.constructor
is
This property has the attributes { [[Writable]]:
The initial value of the
This property has the attributes { [[Writable]]:
Every AsyncFunction instance is an ECMAScript
Each AsyncFunction instance has the following own properties:
The specification for the
The specification for the
The abstract operation AsyncFunctionStart takes arguments promiseCapability (a
The abstract operation AsyncBlockStart takes arguments promiseCapability (a
The abstract operation Await takes argument value (an