mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
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:
1 parent
2bb42bf156
commit
e9944e9a38
1 file changed
+3
-6
@@ -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
|
||||
|
||||
Reference in new issue
Block a user