PHP 7.4.33
Preview: index.js Size: 1.25 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/is-generator-function/index.js
'use strict';

var callBound = require('call-bound');
var safeRegexTest = require('safe-regex-test');
var isFnRegex = safeRegexTest(/^\s*(?:function)?\*/);
var hasToStringTag = require('has-tostringtag/shams')();
var getProto = require('get-proto');

var toStr = callBound('Object.prototype.toString');
var fnToStr = callBound('Function.prototype.toString');

var getGeneratorFunc = function () { // eslint-disable-line consistent-return
	if (!hasToStringTag) {
		return false;
	}
	try {
		return Function('return function*() {}')();
	} catch (e) {
	}
};
/** @type {undefined | false | null | GeneratorFunctionConstructor} */
var GeneratorFunction;

/** @type {import('.')} */
module.exports = function isGeneratorFunction(fn) {
	if (typeof fn !== 'function') {
		return false;
	}
	if (isFnRegex(fnToStr(fn))) {
		return true;
	}
	if (!hasToStringTag) {
		var str = toStr(fn);
		return str === '[object GeneratorFunction]';
	}
	if (!getProto) {
		return false;
	}
	if (typeof GeneratorFunction === 'undefined') {
		var generatorFunc = getGeneratorFunc();
		GeneratorFunction = generatorFunc
			// eslint-disable-next-line no-extra-parens
			? /** @type {GeneratorFunctionConstructor} */ (getProto(generatorFunc))
			: false;
	}
	return getProto(fn) === GeneratorFunction;
};

Directory Contents

Dirs: 1 × Files: 10
Name Size Perms Modified Actions
test DIR
- drwxr-xr-x 2025-03-28 11:04:35
Edit Download
80 B lrw-r--r-- 2025-03-28 11:04:35
Edit Download
5 B lrw-r--r-- 2025-03-28 11:04:35
Edit Download
139 B lrw-r--r-- 2025-03-28 11:04:35
Edit Download
24.69 KB lrw-r--r-- 2025-03-28 11:04:35
Edit Download
106 B lrw-r--r-- 2025-03-28 11:04:35
Edit Download
1.25 KB lrw-r--r-- 2025-03-28 11:04:35
Edit Download
1.06 KB lrw-r--r-- 2025-03-28 11:04:35
Edit Download
2.87 KB lrw-r--r-- 2025-03-28 11:04:35
Edit Download
1.74 KB lrw-r--r-- 2025-03-28 11:04:35
Edit Download
129 B lrw-r--r-- 2025-03-28 11:04:35
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).