An AsyncIterator
object is an object that conforms to the async iterator protocol by providing a next()
method that returns a promise fulfilling to an iterator result object. The AsyncIterator.prototype
object is a hidden global object that all built-in async iterators inherit from. It provides an @@asyncIterator
method that returns the async iterator object itself, making the async iterator also async iterable.
Note that AsyncIterator
is not a global object, although it will be in the future with the async iterator helpers proposal. The AsyncIterator.prototype
object shared by all built-in async iterators can be obtained with the following code:
const AsyncIteratorPrototype = Object.getPrototypeOf( Object.getPrototypeOf(Object.getPrototypeOf((async function* () {})())), );