isAsyncIterable
Checks if a value implements the async iterable protocol.
Returns true for any object that has a [Symbol.asyncIterator]() method,
including async generators. Note that regular iterables (arrays, strings, etc.)
are not async iterables.
Available since v2.0.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
Section titled “Returns”value is AsyncIterable<unknown, any, any> — true if value is async iterable
Examples
Section titled “Examples”Detect an async generator
Section titled “Detect an async generator”Async generators implement the async iterable protocol.
Guard before for-await-of
Section titled “Guard before for-await-of”Use to type-narrow before consuming a value with for-await-of.
