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

    Function isGenerator

    • Checks if the provided value is a GeneratorFunction

      Parameters

      • value: any

        Value to be checked

      Returns value is GeneratorFunction

      True if the value is a GeneratorFunction, false otherwise

      0.12.3

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

      function* genFn() { }
      isGenerator(genFn); // true
      isGenerator(function() {}); // false
      isGenerator(async function() {}); // false
      isGenerator(async function* () {}); // false
      isGenerator(null); // false
      isGenerator(undefined); // false