|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
914 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 | var DESCRIPTORS = require('../internals/descriptors');
|
|---|
| 3 | var FUNCTION_NAME_EXISTS = require('../internals/function-name').EXISTS;
|
|---|
| 4 | var uncurryThis = require('../internals/function-uncurry-this');
|
|---|
| 5 | var defineBuiltInAccessor = require('../internals/define-built-in-accessor');
|
|---|
| 6 |
|
|---|
| 7 | var FunctionPrototype = Function.prototype;
|
|---|
| 8 | var functionToString = uncurryThis(FunctionPrototype.toString);
|
|---|
| 9 | var nameRE = /function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/;
|
|---|
| 10 | var regExpExec = uncurryThis(nameRE.exec);
|
|---|
| 11 | var NAME = 'name';
|
|---|
| 12 |
|
|---|
| 13 | // Function instances `.name` property
|
|---|
| 14 | // https://tc39.es/ecma262/#sec-function-instances-name
|
|---|
| 15 | if (DESCRIPTORS && !FUNCTION_NAME_EXISTS) {
|
|---|
| 16 | defineBuiltInAccessor(FunctionPrototype, NAME, {
|
|---|
| 17 | configurable: true,
|
|---|
| 18 | get: function () {
|
|---|
| 19 | try {
|
|---|
| 20 | return regExpExec(nameRE, functionToString(this))[1];
|
|---|
| 21 | } catch (error) {
|
|---|
| 22 | return '';
|
|---|
| 23 | }
|
|---|
| 24 | }
|
|---|
| 25 | });
|
|---|
| 26 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.