Skip to content

Commit

Permalink
since now make-built-in used in runtime, make some operations unobs…
Browse files Browse the repository at this point in the history
…ervable
  • Loading branch information
zloirock committed Jan 14, 2023
1 parent 0d2f278 commit 64b52bf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/core-js/internals/make-built-in.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var uncurryThis = require('../internals/function-uncurry-this');
var fails = require('../internals/fails');
var isCallable = require('../internals/is-callable');
var hasOwn = require('../internals/has-own-property');
Expand All @@ -8,8 +9,12 @@ var InternalStateModule = require('../internals/internal-state');

var enforceInternalState = InternalStateModule.enforce;
var getInternalState = InternalStateModule.get;
var $String = String;
// eslint-disable-next-line es/no-object-defineproperty -- safe
var defineProperty = Object.defineProperty;
var stringSlice = uncurryThis(''.slice);
var replace = uncurryThis(''.replace);
var join = uncurryThis([].join);

var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
Expand All @@ -18,8 +23,8 @@ var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
var TEMPLATE = String(String).split('String');

var makeBuiltIn = module.exports = function (value, name, options) {
if (String(name).slice(0, 7) === 'Symbol(') {
name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
if (stringSlice($String(name), 0, 7) === 'Symbol(') {
name = '[' + replace($String(name), /^Symbol\(([^)]*)\)/, '$1') + ']';
}
if (options && options.getter) name = 'get ' + name;
if (options && options.setter) name = 'set ' + name;
Expand All @@ -38,7 +43,7 @@ var makeBuiltIn = module.exports = function (value, name, options) {
} catch (error) { /* empty */ }
var state = enforceInternalState(value);
if (!hasOwn(state, 'source')) {
state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
} return value;
};

Expand Down

0 comments on commit 64b52bf

Please sign in to comment.