Socket
Socket
Sign inDemoInstall

is-generator-function

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-generator-function

Determine if a function is an ES6 generator function or not.


Version published
Weekly downloads
15M
decreased by-24.48%
Maintainers
1
Install size
14.2 kB
Created
Weekly downloads
 

Package description

What is is-generator-function?

The is-generator-function package is a utility that allows you to check if a given function is a generator function. This can be particularly useful when working with code that dynamically generates functions or when integrating with libraries that may use generator functions for asynchronous control flow.

What are is-generator-function's main functionalities?

Check if a function is a generator function

This feature allows you to distinguish between regular JavaScript functions and generator functions. By passing a function to `isGeneratorFunction`, it returns `true` if the function is a generator function and `false` otherwise. This can be useful for dynamic function handling or when working with APIs that may provide generator functions.

const isGeneratorFunction = require('is-generator-function');

function* myGenerator() {}
const regularFunction = function() {};

console.log(isGeneratorFunction(myGenerator)); // true
console.log(isGeneratorFunction(regularFunction)); // false

Other packages similar to is-generator-function

Changelog

Source

v1.0.3 - 2015-01-31

Commits

  • make release 209fac4
  • Run tests against a faked @@toStringTag c9ba1ea
  • Add sudo: false to speed up travis-ci tests. a4b41e1
  • Bail out early when typeof is not "function" a62e7a5

Readme

Source

#is-generator-function Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

browser support

Is this an ES6 generator function?

Example

var isGeneratorFunction = require('is-generator-function');
assert(!isGeneratorFunction(function () {}));
assert(!isGeneratorFunction(null));
assert(isGeneratorFunction(function* () { yield 42; return Infinity; });

Tests

Simply clone the repo, npm install, and run npm test

Keywords

FAQs

Last updated on 31 Jan 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc