2017-04-20 03:09:25 +02:00
|
|
|
var setDesc = require('./$').setDesc
|
|
|
|
, createDesc = require('./$.property-desc')
|
|
|
|
, has = require('./$.has')
|
2016-10-10 03:43:44 +02:00
|
|
|
, FProto = Function.prototype
|
|
|
|
, nameRE = /^\s*function ([^ (]*)/
|
|
|
|
, NAME = 'name';
|
|
|
|
// 19.2.4.2 name
|
2017-04-20 03:09:25 +02:00
|
|
|
NAME in FProto || require('./$.descriptors') && setDesc(FProto, NAME, {
|
2016-10-10 03:43:44 +02:00
|
|
|
configurable: true,
|
|
|
|
get: function(){
|
2017-04-20 03:09:25 +02:00
|
|
|
var match = ('' + this).match(nameRE)
|
|
|
|
, name = match ? match[1] : '';
|
|
|
|
has(this, NAME) || setDesc(this, NAME, createDesc(5, name));
|
|
|
|
return name;
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
});
|