File tree Expand file tree Collapse file tree 2 files changed +4
-19
lines changed Expand file tree Collapse file tree 2 files changed +4
-19
lines changed Original file line number Diff line number Diff line change @@ -9,17 +9,7 @@ var getProto = require('get-proto');
99var toStr = callBound ( 'Object.prototype.toString' ) ;
1010var fnToStr = callBound ( 'Function.prototype.toString' ) ;
1111
12- var getGeneratorFunc = function ( ) { // eslint-disable-line consistent-return
13- if ( ! hasToStringTag ) {
14- return false ;
15- }
16- try {
17- return Function ( 'return function*() {}' ) ( ) ;
18- } catch ( e ) {
19- }
20- } ;
21- /** @type {undefined | false | null | GeneratorFunctionConstructor } */
22- var GeneratorFunction ;
12+ var getGeneratorFunction = require ( 'generator-function' ) ;
2313
2414/** @type {import('.') } */
2515module . exports = function isGeneratorFunction ( fn ) {
@@ -36,12 +26,6 @@ module.exports = function isGeneratorFunction(fn) {
3626 if ( ! getProto ) {
3727 return false ;
3828 }
39- if ( typeof GeneratorFunction === 'undefined' ) {
40- var generatorFunc = getGeneratorFunc ( ) ;
41- GeneratorFunction = generatorFunc
42- // eslint-disable-next-line no-extra-parens
43- ? /** @type {GeneratorFunctionConstructor } */ ( getProto ( generatorFunc ) )
44- : false ;
45- }
46- return getProto ( fn ) === GeneratorFunction ;
29+ var GeneratorFunction = getGeneratorFunction ( ) ;
30+ return GeneratorFunction && getProto ( fn ) === GeneratorFunction ;
4731} ;
Original file line number Diff line number Diff line change 4444 },
4545 "dependencies" : {
4646 "call-bound" : " ^1.0.3" ,
47+ "generator-function" : " ^2.0.0" ,
4748 "get-proto" : " ^1.0.0" ,
4849 "has-tostringtag" : " ^1.0.2" ,
4950 "safe-regex-test" : " ^1.1.0"
You can’t perform that action at this time.
0 commit comments