util: prefer Reflect.ownKeys(…)

PR-URL: https://github.com/nodejs/node/pull/36740
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
ExE Boss authored and Antoine du Hamel committed 2021-01-20 01:25:17 +01:00
1 parent 2bb42bf156
commit e9944e9a38
1 file changed
+3 -6
+3 -6
View File
@@ -43,6 +43,7 @@ const {
ObjectPrototypePropertyIsEnumerable,
ObjectSeal,
ObjectSetPrototypeOf,
ReflectOwnKeys,
RegExp,
RegExpPrototypeTest,
RegExpPrototypeToString,
@@ -615,11 +616,7 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, output) {
ArrayPrototypeForEach(keys, (key) => keySet.add(key));
}
// Get all own property names and symbols.
keys = ObjectGetOwnPropertyNames(obj);
const symbols = ObjectGetOwnPropertySymbols(obj);
if (symbols.length !== 0) {
ArrayPrototypePush(keys, ...symbols);
}
keys = ReflectOwnKeys(obj);
for (const key of keys) {
// Ignore the `constructor` property and keys that exist on layers above.
if (key === 'constructor' ||
@@ -667,7 +664,7 @@ function getKeys(value, showHidden) {
if (showHidden) {
keys = ObjectGetOwnPropertyNames(value);
if (symbols.length !== 0)
keys.push(...symbols);
ArrayPrototypePush(keys, ...symbols);
} else {
// This might throw if `value` is a Module Namespace Object from an
// unevaluated module, but we don't want to perform the actual type