es6.function.name.js 355 B

12345678910111213141516
  1. var dP = require('./_object-dp').f;
  2. var FProto = Function.prototype;
  3. var nameRE = /^\s*function ([^ (]*)/;
  4. var NAME = 'name';
  5. // 19.2.4.2 name
  6. NAME in FProto || require('./_descriptors') && dP(FProto, NAME, {
  7. configurable: true,
  8. get: function () {
  9. try {
  10. return ('' + this).match(nameRE)[1];
  11. } catch (e) {
  12. return '';
  13. }
  14. }
  15. });