* 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)
| 909 | * @returns {Function} the same function, renamed |
| 910 | */ |
| 911 | function 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 | |
| 928 | module.exports = { |
| 929 | getLazy, |
no test coverage detected
searching dependent graphs…