Sha256: 62ead43fc810a987544675c706fd4d6bc849f5e86e61ca38dc9cc71e74bd97b8

Contents?: true

Size: 744 Bytes

Versions: 14

Compression:

Stored size: 744 Bytes

Contents

'use strict';

var define = require('define-data-property');
var hasDescriptors = require('has-property-descriptors')();
var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames();

var $TypeError = require('es-errors/type');

/** @type {import('.')} */
module.exports = function setFunctionName(fn, name) {
	if (typeof fn !== 'function') {
		throw new $TypeError('`fn` is not a function');
	}
	var loose = arguments.length > 2 && !!arguments[2];
	if (!loose || functionsHaveConfigurableNames) {
		if (hasDescriptors) {
			define(/** @type {Parameters<define>[0]} */ (fn), 'name', name, true, true);
		} else {
			define(/** @type {Parameters<define>[0]} */ (fn), 'name', name);
		}
	}
	return fn;
};

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.51 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.50 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.49 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.48 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.47 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.46 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.45 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.44 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.43 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.42 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.41 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.40 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.39 node_modules/set-function-name/index.js
immosquare-cleaner-0.1.38 node_modules/set-function-name/index.js