source: frontend/node_modules/is-generator-function/index.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 860 bytes
Line 
1'use strict';
2
3var callBound = require('call-bound');
4var safeRegexTest = require('safe-regex-test');
5var isFnRegex = safeRegexTest(/^\s*(?:function)?\*/);
6var hasToStringTag = require('has-tostringtag/shams')();
7var getProto = require('get-proto');
8
9var toStr = callBound('Object.prototype.toString');
10var fnToStr = callBound('Function.prototype.toString');
11
12var getGeneratorFunction = require('generator-function');
13
14/** @type {import('.')} */
15module.exports = function isGeneratorFunction(fn) {
16 if (typeof fn !== 'function') {
17 return false;
18 }
19 if (isFnRegex(fnToStr(fn))) {
20 return true;
21 }
22 if (!hasToStringTag) {
23 var str = toStr(fn);
24 return str === '[object GeneratorFunction]';
25 }
26 if (!getProto) {
27 return false;
28 }
29 var GeneratorFunction = getGeneratorFunction();
30 return GeneratorFunction && getProto(fn) === GeneratorFunction.prototype;
31};
Note: See TracBrowser for help on using the repository browser.