MCPcopy Index your code
hub / github.com/nodejs/node / assignFunctionName

Function assignFunctionName

lib/internal/util.js:911–926  ·  view source on GitHub ↗

* Reassigns the .name property of a function. * Should be used when function can't be initially defined with desired name * or when desired name should include `#`, `[`, `]`, etc. * @param {string | symbol} name * @param {Function} fn * @param {object} [descriptor] * @returns {Function} the sa

(name, fn, descriptor = kEmptyObject)

Source from the content-addressed store, hash-verified

909 * @returns {Function} the same function, renamed
910 */
911function assignFunctionName(name, fn, descriptor = kEmptyObject) {
912 if (typeof name !== 'string') {
913 const symbolDescription = SymbolPrototypeGetDescription(name);
914 assert(symbolDescription !== undefined, 'Attempted to name function after descriptionless Symbol');
915 name = `[${symbolDescription}]`;
916 }
917 return ObjectDefineProperty(fn, 'name', {
918 __proto__: null,
919 writable: false,
920 enumerable: false,
921 configurable: true,
922 ...ObjectGetOwnPropertyDescriptor(fn, 'name'),
923 ...descriptor,
924 value: name,
925 });
926}
927
928module.exports = {
929 getLazy,

Callers 7

_http_outgoing.jsFile · 0.85
_http_server.jsFile · 0.85
interface.jsFile · 0.85
io.jsFile · 0.85
core.jsFile · 0.85

Calls 1

assertFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…