Skip to content

Commit

Permalink
fix Function#name
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Oct 24, 2021
1 parent 61ebde0 commit 0a2f57b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core-js/modules/es.function.name.js
Expand Up @@ -6,7 +6,7 @@ var defineProperty = require('../internals/object-define-property').f;
var FunctionPrototype = Function.prototype;
var functionToString = uncurryThis(FunctionPrototype.toString);
var nameRE = /^\s*function ([^ (]*)/;
var regExpMatch = uncurryThis(nameRE.match);
var regExpExec = uncurryThis(nameRE.exec);
var NAME = 'name';

// Function instances `.name` property
Expand All @@ -16,7 +16,7 @@ if (DESCRIPTORS && !FUNCTION_NAME_EXISTS) {
configurable: true,
get: function () {
try {
return regExpMatch(functionToString(this), nameRE)[1];
return regExpExec(nameRE, functionToString(this))[1];
} catch (error) {
return '';
}
Expand Down

0 comments on commit 0a2f57b

Please sign in to comment.