Socket
Socket
Sign inDemoInstall

is-generator-fn

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-generator-fn

Check if something is a generator function


Version published
Weekly downloads
19M
increased by0.16%
Maintainers
1
Install size
3.92 kB
Created
Weekly downloads
 

Package description

What is is-generator-fn?

The is-generator-fn package is a simple utility that allows you to check if a given function is a generator function. This can be particularly useful when working with or developing libraries that need to handle generator functions differently from regular functions, or when you want to enforce that a certain function passed to your code is a generator function for execution purposes.

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

Check if a function is a generator function

This feature allows you to distinguish between generator functions and regular functions. By passing a function to `isGeneratorFn`, it returns `true` if the function is a generator function and `false` otherwise. This can be useful in scenarios where specific handling or behavior is required for generator functions.

const isGeneratorFn = require('is-generator-fn');

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

console.log(isGeneratorFn(generatorFunction)); // true
console.log(isGeneratorFn(regularFunction)); // false

Other packages similar to is-generator-fn

Readme

Source

is-generator-fn

Check if something is a generator function

Install

$ npm install is-generator-fn

Usage

import isGeneratorFunction from 'is-generator-fn';

isGeneratorFunction(function * () {});
//=> true

isGeneratorFunction(function () {});
//=> false
  • is - Type check values

Keywords

FAQs

Last updated on 11 Aug 2021

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