Skip to content

Commit

Permalink
avoid usage forEach from prototype on runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 3, 2023
1 parent 4f3cf90 commit 5b64b45
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/core-js/modules/es.symbol.constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
var nativeDefineProperty = definePropertyModule.f;
var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
var forEach = uncurryThis([].forEach);
var push = uncurryThis([].push);

var AllSymbols = shared('symbols');
Expand Down Expand Up @@ -106,7 +107,7 @@ var $defineProperty = function defineProperty(O, P, Attributes) {
var $defineProperties = function defineProperties(O, Properties) {
anObject(O);
var properties = toObject(Properties);
nativeObjectKeys(properties).concat($getOwnPropertySymbols(properties)).forEach(function (key) {
forEach(nativeObjectKeys(properties).concat($getOwnPropertySymbols(properties)), function (key) {
if (call($propertyIsEnumerable, properties, key)) $defineProperty(O, key, properties[key]);
});
return O;
Expand Down Expand Up @@ -137,7 +138,7 @@ var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {

var $getOwnPropertyNames = function getOwnPropertyNames(O) {
var result = [];
nativeGetOwnPropertyNames(toObject(O)).forEach(function (key) {
forEach(nativeGetOwnPropertyNames(toObject(O)), function (key) {
if (!hasOwn(AllSymbols, key) && !hasOwn(hiddenKeys, key)) push(result, key);
});
return result;
Expand All @@ -146,7 +147,7 @@ var $getOwnPropertyNames = function getOwnPropertyNames(O) {
var $getOwnPropertySymbols = function (O) {
var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
var result = [];
nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toObject(O)).forEach(function (key) {
forEach(nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toObject(O)), function (key) {
if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) {
push(result, AllSymbols[key]);
}
Expand Down Expand Up @@ -214,7 +215,7 @@ $({ global: true, constructor: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !
Symbol: $Symbol,
});

nativeObjectKeys(WellKnownSymbolsStore).forEach(function (name) {
forEach(nativeObjectKeys(WellKnownSymbolsStore), function (name) {
defineWellKnownSymbol(name);
});

Expand Down

0 comments on commit 5b64b45

Please sign in to comment.