Skip to content

isAsyncFunction ​

The isAsyncFunction function checks if the provided value is an async function.

Syntax ​

typescript
isAsyncFunction(value: any): value is (...args: any[]) => Promise<any>;

Parameters ​

ParameterTypeDescription
valueanyValue to be checked

Returns ​

TypeDescription
booleanTrue if it is an async function

Examples ​

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

Notes ​

  • Useful for validating functions before using await.

References ​

Released under the MIT License.