2017-05-27 17:36:13 +02:00
|
|
|
var dP = require('./_object-dp').f
|
|
|
|
, createDesc = require('./_property-desc')
|
|
|
|
, has = require('./_has')
|
2016-10-10 03:43:44 +02:00
|
|
|
, FProto = Function.prototype
|
|
|
|
, nameRE = /^\s*function ([^ (]*)/
|
|
|
|
, NAME = 'name';
|
2017-05-27 17:36:13 +02:00
|
|
|
|
|
|
|
var isExtensible = Object.isExtensible || function(){
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2016-10-10 03:43:44 +02:00
|
|
|
// 19.2.4.2 name
|
2017-05-27 17:36:13 +02:00
|
|
|
NAME in FProto || require('./_descriptors') && dP(FProto, NAME, {
|
2016-10-10 03:43:44 +02:00
|
|
|
configurable: true,
|
|
|
|
get: function(){
|
2017-05-27 17:36:13 +02:00
|
|
|
try {
|
|
|
|
var that = this
|
|
|
|
, name = ('' + that).match(nameRE)[1];
|
|
|
|
has(that, NAME) || !isExtensible(that) || dP(that, NAME, createDesc(5, name));
|
|
|
|
return name;
|
|
|
|
} catch(e){
|
|
|
|
return '';
|
|
|
|
}
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
});
|