is-gen-func

Check if value is a generator function

Usage no npm install needed!

<script type="module">
  import isGenFunc from 'https://cdn.skypack.dev/is-gen-func';
</script>

README

is-gen-func

CircleCI NPM Downloads node License MIT

Check if value is a generator function or an async generator function

Highlights

  • Written in Typescript

  • Supports async and sync generator functions

Installation

npm:

$ npm install is-gen-func

yarn:

$ yarn add is-gen-func

Usage

Check if value is a generator function


  const { isGenFunc } = require('is-gen-func');

  isGenFunc(function *() {
    return 'hello world';
  });
  //=> true

  isGenFunc(function () {
    return 'hello world';
  });
  //=> false

  isGenFunc(async function *() {
    return 'hello world';
  });
  //=> true

  isGenFunc(async function () {
    return 'hello world';
  });
  //=> false

License

MIT © Nivrith