is-generator-function
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -8,2 +8,3 @@ 'use strict'; | ||
module.exports = function isGeneratorFunction(fn) { | ||
if (typeof fn !== 'function') { return false; } | ||
var fnStr = toStr.call(fn); | ||
@@ -10,0 +11,0 @@ return (fnStr === '[object Function]' || fnStr === '[object GeneratorFunction]') && isFnRegex.test(fnToStr.call(fn)); |
{ | ||
"name": "is-generator-function", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Determine if a function is an ES6 generator function or not.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "npm run lint && node --harmony test/index.js", | ||
"test": "npm run lint && node --es-staging --harmony test/index.js", | ||
"coverage": "covert test/index.js", | ||
@@ -34,3 +34,4 @@ "coverage-quiet": "covert test/index.js --quiet", | ||
"covert": "1.0.0", | ||
"jscs": "~1.10.0" | ||
"jscs": "~1.10.0", | ||
"semver": "~4.2.0" | ||
}, | ||
@@ -37,0 +38,0 @@ "testling": { |
@@ -6,2 +6,3 @@ 'use strict'; | ||
var generatorFunc = require('make-generator-function'); | ||
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; | ||
@@ -59,2 +60,8 @@ var forEach = function (arr, func) { | ||
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); } }; | ||
fakeGenFunction[Symbol.toStringTag] = 'GeneratorFunction'; | ||
t.notOk(isGeneratorFunction(fakeGenFunction), 'fake GeneratorFunction with @@toStringTag "GeneratorFunction" is not a generator function'); | ||
t.end(); | ||
}); | ||
@@ -61,0 +68,0 @@ test('returns true for generator functions', function (t) { |
Sorry, the diff of this file is not supported yet
13549
11
113
5