JavaScript AsyncIterator : AsyncIterable

An AsyncIterator is an Object that returns a sequence of Promises. Since AsyncIterators are AsyncIterables, you can use for await (const value of iterable) {} to easily loop over the values in an AsyncIterator. Calling an async generator function (async function* () {}) returns an AsyncIterable. You may create your own AsyncIterable object by assigning the Symbol.asyncIterator property to an object with a next() method.

Example:

Run

Results:

 

Instance Indexers

Returns a method that returns this.

Example:

Run

Results:

 

Instance Methods

next([yieldValue : Object]) : Promise

Promise return type: { value : Object, done : Boolean }

return([yieldValue : Object]) : Promise

throw([rejectReason : Object]) : Promise