Type guard to check if an iterable is an async iterable.
Determines whether the given iterable implements the async iterator protocol by checking for the presence of the Symbol.asyncIterator method.
Symbol.asyncIterator
The type of values in the iterable
The type of the return value (default: any)
any
The type of values that can be passed to next() (default: undefined)
next()
undefined
The iterable to check
true if the iterable is async, false otherwise
true
false
const syncGen = function* () { yield 1; }();const asyncGen = async function* () { yield 1; }();isAsyncIterable(syncGen); // falseisAsyncIterable(asyncGen); // true Copy
const syncGen = function* () { yield 1; }();const asyncGen = async function* () { yield 1; }();isAsyncIterable(syncGen); // falseisAsyncIterable(asyncGen); // true
Type guard to check if an iterable is an async iterable.
Determines whether the given iterable implements the async iterator protocol by checking for the presence of the
Symbol.asyncIteratormethod.