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
19M
decreased by-6.96%
Maintainers
1
Install size
710 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.4 - 2015-03-03

Fixed

  • Add support for detecting concise generator methods. #2

Commits

  • All grade A-supported node/iojs versions now ship with an npm that understands ^. 6562e80
  • Run travis-ci tests on iojs and node v0.12; speed up builds; allow 0.8 failures. 592f768
  • Test on latest io.js edca329
  • Forgot to add replace in 209fac444b4bd90eaa8df279457c4a15e6bba6d2 3ebfb38
  • Update semver c21baa5
  • Update jscs 71a68f4
  • Update tape 32c03cf

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 20 Dec 2016

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