|
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 |
|
|---|
| 3 | var callBound = require('call-bound');
|
|---|
| 4 | var safeRegexTest = require('safe-regex-test');
|
|---|
| 5 | var isFnRegex = safeRegexTest(/^\s*(?:function)?\*/);
|
|---|
| 6 | var hasToStringTag = require('has-tostringtag/shams')();
|
|---|
| 7 | var getProto = require('get-proto');
|
|---|
| 8 |
|
|---|
| 9 | var toStr = callBound('Object.prototype.toString');
|
|---|
| 10 | var fnToStr = callBound('Function.prototype.toString');
|
|---|
| 11 |
|
|---|
| 12 | var getGeneratorFunction = require('generator-function');
|
|---|
| 13 |
|
|---|
| 14 | /** @type {import('.')} */
|
|---|
| 15 | module.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.