🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

is-generator-function

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-generator-function - npm Package Compare versions

Comparing version

to
1.0.5

.eslintrc

116

.jscs.json
{
"es3": true,
"additionalRules": [],
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
"requireSemicolons": true,
"disallowMultipleSpaces": true,
"disallowIdentifierNames": [],
"requireCurlyBraces": {
"allExcept": [],
"keywords": ["if", "else", "for", "while", "do", "try", "catch"]
},
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"],

@@ -10,2 +21,17 @@

"disallowSpaceBeforeComma": true,
"disallowSpaceAfterComma": false,
"disallowSpaceBeforeSemicolon": true,
"disallowNodeTypes": [
"DebuggerStatement",
"ForInStatement",
"LabeledStatement",
"SwitchCase",
"SwitchStatement",
"WithStatement"
],
"requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] },
"requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },

@@ -23,3 +49,3 @@ "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true },

"disallowQuotedKeysInObjects": "allButReserved",
"disallowQuotedKeysInObjects": { "allExcept": ["reserved"] },

@@ -59,3 +85,3 @@ "disallowSpaceAfterObjectKeys": true,

"requireDotNotation": true,
"requireDotNotation": { "allExcept": ["keywords"] },

@@ -69,4 +95,86 @@ "requireParenthesesAroundIIFE": true,

"mark": "'"
}
},
"disallowOperatorBeforeLineBreak": [],
"requireSpaceBeforeKeywords": [
"do",
"for",
"if",
"else",
"switch",
"case",
"try",
"catch",
"finally",
"while",
"with",
"return"
],
"validateAlignedFunctionParameters": {
"lineBreakAfterOpeningBraces": true,
"lineBreakBeforeClosingBraces": true
},
"requirePaddingNewLinesBeforeExport": true,
"validateNewlineAfterArrayElements": {
"maximum": 1
},
"requirePaddingNewLinesAfterUseStrict": true,
"disallowArrowFunctions": true,
"disallowMultiLineTernary": true,
"validateOrderInObjectKeys": "asc-insensitive",
"disallowIdenticalDestructuringNames": true,
"disallowNestedTernaries": { "maxLevel": 1 },
"requireSpaceAfterComma": { "allExcept": ["trailing"] },
"requireAlignedMultilineParams": false,
"requireSpacesInGenerator": {
"afterStar": true
},
"disallowSpacesInGenerator": {
"beforeStar": true
},
"disallowVar": false,
"requireArrayDestructuring": false,
"requireEnhancedObjectLiterals": false,
"requireObjectDestructuring": false,
"requireEarlyReturn": false,
"requireCapitalizedConstructorsNew": {
"allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"]
},
"requireImportAlphabetized": false,
"requireSpaceBeforeObjectValues": true,
"requireSpaceBeforeDestructuredValues": true,
"disallowSpacesInsideTemplateStringPlaceholders": true,
"disallowArrayDestructuringReturn": false,
"requireNewlineBeforeSingleStatementsInIf": false,
"disallowUnusedVariables": true,
"requireSpacesInsideImportedObjectBraces": true,
"requireUseStrict": true
}

@@ -0,1 +1,15 @@

1.0.5 / 2016-12-19
=================
* [Fix] account for Safari 10 which reports the wrong toString on generator functions
* [Refactor] remove useless `Object#toString` check
* [Dev Deps] update everything; add linting
* [Tests] use pretest/posttest for linting/security
* [Tests] on all minors of node and io.js
1.0.4 / 2015-03-03
=================
* Add support for concise generator methods (#2) This is a patch change since concise methods are not in any actual released engines yet.
* Test on latest `io.js`
* Update `semver`
1.0.3 / 2015-01-31

@@ -2,0 +16,0 @@ =================

20

index.js

@@ -5,9 +5,19 @@ 'use strict';

var fnToStr = Function.prototype.toString;
var isFnRegex = /^\s*function\*/;
var isFnRegex = /^\s*(?:function)?\*/;
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
var getProto = Object.getPrototypeOf;
var GeneratorFunction = hasToStringTag ? getProto(Function('return function*() {}')()) : {};
module.exports = function isGeneratorFunction(fn) {
if (typeof fn !== 'function') { return false; }
var fnStr = toStr.call(fn);
return (fnStr === '[object Function]' || fnStr === '[object GeneratorFunction]') && isFnRegex.test(fnToStr.call(fn));
if (typeof fn !== 'function') {
return false;
}
if (isFnRegex.test(fnToStr.call(fn))) {
return true;
}
if (!hasToStringTag) {
var str = toStr.call(fn);
return str === '[object GeneratorFunction]';
}
return getProto(fn) === GeneratorFunction;
};
{
"name": "is-generator-function",
"version": "1.0.3",
"version": "1.0.5",
"description": "Determine if a function is an ES6 generator function or not.",
"main": "index.js",
"scripts": {
"test": "npm run lint && node --es-staging --harmony test/index.js",
"pretest": "npm run lint",
"test": "npm run tests-only",
"tests-only": "node --es-staging --harmony test/index.js",
"posttest": "npm run security",
"coverage": "covert test/index.js",
"coverage-quiet": "covert test/index.js --quiet",
"lint": "jscs *.js */*.js"
"lint": "npm run jscs && npm run eslint",
"jscs": "jscs *.js */*.js",
"eslint": "eslint *.js */*.js",
"security": "nsp check"
},

@@ -31,7 +37,11 @@ "repository": {

"devDependencies": {
"make-generator-function": "~1.0.0",
"tape": "~3.4.0",
"covert": "1.0.0",
"jscs": "~1.10.0",
"semver": "~4.2.0"
"make-generator-function": "^1.1.0",
"tape": "^4.6.3",
"covert": "^1.1.0",
"jscs": "^3.0.7",
"eslint": "^3.12.2",
"@ljharb/eslint-config": "^9.0.1",
"semver": "^5.3.0",
"replace": "^0.3.0",
"nsp": "^2.6.2"
},

@@ -38,0 +48,0 @@ "testling": {

@@ -28,3 +28,3 @@ #is-generator-function <sup>[![Version Badge][2]][1]</sup>

[1]: https://npmjs.org/package/is-generator-function
[2]: http://vb.teelaun.ch/ljharb/is-generator-function.svg
[2]: http://versionbadg.es/ljharb/is-generator-function.svg
[3]: https://travis-ci.org/ljharb/is-generator-function.svg

@@ -31,0 +31,0 @@ [4]: https://travis-ci.org/ljharb/is-generator-function

'use strict';
/* globals window */
var test = require('tape');

@@ -42,6 +44,6 @@ var isGeneratorFunction = require('../index');

if (typeof window !== 'undefined') {
if (typeof window === 'undefined') {
t.skip('window.alert is not an generator function');
} else {
t.notOk(isGeneratorFunction(window.alert), 'window.alert is not an generator function');
} else {
t.skip('window.alert is not an generator function');
}

@@ -61,3 +63,6 @@ t.end();

test('returns false for non-generator function with faked @@toStringTag', { skip: !hasToStringTag }, function (t) {
var fakeGenFunction = { valueOf: function () { return generatorFunc; }, toString: function () { return String(generatorFunc); } };
var fakeGenFunction = {
toString: function () { return String(generatorFunc); },
valueOf: function () { return generatorFunc; }
};
fakeGenFunction[Symbol.toStringTag] = 'GeneratorFunction';

@@ -77,1 +82,16 @@ t.notOk(isGeneratorFunction(fakeGenFunction), 'fake GeneratorFunction with @@toStringTag "GeneratorFunction" is not a generator function');

test('concise methods', { skip: !generatorFunc || !generatorFunc.concise }, function (t) {
t.test('returns true for concise generator methods', function (st) {
st.ok(isGeneratorFunction(generatorFunc.concise), 'concise generator method is generator function');
st.end();
});
t.test('returns false for concise non-generator methods', function (st) {
var conciseMethod = Function('return { concise() {} }.concise;')();
st.equal(typeof conciseMethod, 'function', 'assert: concise method exists');
st.notOk(isGeneratorFunction(conciseMethod), 'concise non-generator method is not generator function');
st.end();
});
t.end();
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet