Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
673 bytes
|
Line | |
---|
1 | var DESCRIPTORS = require('../internals/descriptors');
|
---|
2 | var defineProperty = require('../internals/object-define-property').f;
|
---|
3 |
|
---|
4 | var FunctionPrototype = Function.prototype;
|
---|
5 | var FunctionPrototypeToString = FunctionPrototype.toString;
|
---|
6 | var nameRE = /^\s*function ([^ (]*)/;
|
---|
7 | var NAME = 'name';
|
---|
8 |
|
---|
9 | // Function instances `.name` property
|
---|
10 | // https://tc39.es/ecma262/#sec-function-instances-name
|
---|
11 | if (DESCRIPTORS && !(NAME in FunctionPrototype)) {
|
---|
12 | defineProperty(FunctionPrototype, NAME, {
|
---|
13 | configurable: true,
|
---|
14 | get: function () {
|
---|
15 | try {
|
---|
16 | return FunctionPrototypeToString.call(this).match(nameRE)[1];
|
---|
17 | } catch (error) {
|
---|
18 | return '';
|
---|
19 | }
|
---|
20 | }
|
---|
21 | });
|
---|
22 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.