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