Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
is-generator
Advanced tools
The is-generator npm package is a utility for checking if a given value is a generator function or a generator object. This can be useful in various scenarios where you need to handle generator functions or objects differently from other types of functions or objects.
Check if a value is a generator function
This feature allows you to check if a given function is a generator function. The `isGenerator.fn` method returns true if the input is a generator function and false otherwise.
const isGenerator = require('is-generator');
function* genFunc() {}
console.log(isGenerator.fn(genFunc)); // true
console.log(isGenerator.fn(function() {})); // false
Check if a value is a generator object
This feature allows you to check if a given value is a generator object. The main `isGenerator` method returns true if the input is a generator object and false otherwise.
const isGenerator = require('is-generator');
function* genFunc() {}
const genObj = genFunc();
console.log(isGenerator(genObj)); // true
console.log(isGenerator({})); // false
The is-generator-function package provides a utility to check if a given function is a generator function. It is similar to the `isGenerator.fn` method in the is-generator package but does not provide functionality to check for generator objects.
The is-gen-fn package is another utility for checking if a function is a generator function. It is similar to `isGenerator.fn` but is a smaller, more focused package that only provides this single functionality.
Check whether a value is a generator or generator function.
Generator: A specific type of iterator object. Reference.
Generator Function: A function*
declaration, returns a generator object. Reference.
npm install is-generator --save
var isGenerator = require('is-generator')
var isGeneratorFn = require('is-generator').fn
isGenerator(null) //=> false
isGenerator(function * () {}) //=> false
isGenerator((function * () {})()) //=> true
isGeneratorFn(null) //=> false
isGeneratorFn(function () {}) //=> false
isGeneratorFn(function * () {}) //=> true
MIT
FAQs
Check whether a value is a generator or generator function
The npm package is-generator receives a total of 674,751 weekly downloads. As such, is-generator popularity was classified as popular.
We found that is-generator 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.