
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
is-generator-fn
Advanced tools
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.
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
Similar to is-generator-fn, is-generator checks if a given value is a generator object, which is different from checking if a function is a generator function. While is-generator-fn checks the function definition, is-generator checks the runtime object produced by calling a generator function.
This package offers functionality similar to is-generator-fn by providing a way to determine if a function is a generator function. The main difference might be in implementation details or updates, but both packages serve the same purpose of identifying generator functions.
Check if something is a generator function
$ npm install is-generator-fn
import isGeneratorFunction from 'is-generator-fn';
isGeneratorFunction(function * () {});
//=> true
isGeneratorFunction(function () {});
//=> false
FAQs
Check if something is a generator function
The npm package is-generator-fn receives a total of 22,439,681 weekly downloads. As such, is-generator-fn popularity was classified as popular.
We found that is-generator-fn demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.