Skip to content

isAsyncGeneratorFunction ​

The isAsyncGeneratorFunction function checks if the provided value is an async generator function.

Syntax ​

typescript
isAsyncGeneratorFunction(value: any): value is AsyncGeneratorFunction;

Parameters ​

ParameterTypeDescription
valueanyValue to be checked

Returns ​

TypeDescription
booleanTrue if it is an async generator function

Examples ​

typescript
isAsyncGeneratorFunction(async function* () {}); // => true
isAsyncGeneratorFunction(function* () {}); // => false

Notes ​

  • Useful for validating functions before using for-await-of.

References ​

Released under the MIT License.