
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
is-generator-function
Advanced tools
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.
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
Similar to is-generator-function, is-generator checks if a given value is a generator object, which is different from checking if a function is a generator function. It's useful for identifying generator objects, but not for identifying generator functions directly.
While is-function is more general and checks if a given value is a function, it does not specifically differentiate between regular functions and generator functions. It's broader in scope compared to is-generator-function, which is specifically designed to identify generator functions.
Is this a native generator function?
var isGeneratorFunction = require('is-generator-function');
assert(!isGeneratorFunction(function () {}));
assert(!isGeneratorFunction(null));
assert(isGeneratorFunction(function* () { yield 42; return Infinity; }));
Simply clone the repo, npm install
, and run npm test
v1.1.0 - 2025-01-02
7301651
40f30a5
npmignore
to autogenerate an npmignore file ec843a4
6dd27c4
717f85e
eslint
, @ljharb/eslint-config
, safe-publish-latest
, tape
4280e62
895c2d0
for-each
3caee87
call-bound
1eb55de
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, object-inspect
, tape
5bbd4cd
safe-regex-test
5f8b992
@ljharb/eslint-config
, auto-changelog
, npmignore
, tape
c730f4c
get-proto
6dfff38
aud
with npm audit
725db70
has-tostringtag
5cc3c2d
869a507
FAQs
Determine if a function is a native generator function.
The npm package is-generator-function receives a total of 36,309,634 weekly downloads. As such, is-generator-function popularity was classified as popular.
We found that is-generator-function demonstrated a healthy version release cadence and project activity because the last version was released less than 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.