@nevware21/ts-utils
    Preparing search index...

    Function isAsyncFunction

    • Checks if the provided value is an AsyncFunction

      Parameters

      • value: any

        Value to be checked

      Returns value is Function

      True if the value is an AsyncFunction, false otherwise

      0.12.3

      This function checks if the provided value is an AsyncFunction, which is a special type of function that returns a Promise and can be used with the await keyword. Note that this function does not check if the function is a generator or an async generator function. And when using TypeScript and targetting earlier versions of JavaScript, the type of the function may NOT be AsyncFunction and instead be a regular function. This is because the type of the function is determined by the JavaScript engine and not the TypeScript compiler.

      async function asyncFn() { }
      isAsyncFunction(asyncFn); // true
      isAsyncFunction(function() {}); // false
      isAsyncFunction(function* () {}); // false
      isAsyncFunction(async function* () {}); // false
      isAsyncFunction(null); // false
      isAsyncFunction(undefined); // false