massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / es.function.name.js
1 var DESCRIPTORS = require('../internals/descriptors');
2 var FUNCTION_NAME_EXISTS = require('../internals/function-name').EXISTS;
3 var uncurryThis = require('../internals/function-uncurry-this');
4 var defineProperty = require('../internals/object-define-property').f;
5
6 var FunctionPrototype = Function.prototype;
7 var functionToString = uncurryThis(FunctionPrototype.toString);
8 var nameRE = /function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/;
9 var regExpExec = uncurryThis(nameRE.exec);
10 var NAME = 'name';
11
12 // Function instances `.name` property
13 // https://tc39.es/ecma262/#sec-function-instances-name
14 if (DESCRIPTORS && !FUNCTION_NAME_EXISTS) {
15   defineProperty(FunctionPrototype, NAME, {
16     configurable: true,
17     get: function () {
18       try {
19         return regExpExec(nameRE, functionToString(this))[1];
20       } catch (error) {
21         return '';
22       }
23     }
24   });
25 }