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:
RunResults:
Copyright © JavaScripture Contributors