Skip to content

Commit e1cce62

Browse files
committed
util: prefer Reflect.ownKeys(…)
1 parent 873d21c commit e1cce62

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/internal/util/inspect.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const {
4242
ObjectPrototypePropertyIsEnumerable,
4343
ObjectSeal,
4444
ObjectSetPrototypeOf,
45+
ReflectOwnKeys,
4546
RegExp,
4647
RegExpPrototypeTest,
4748
RegExpPrototypeToString,
@@ -612,11 +613,7 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, output) {
612613
keys.forEach((key) => keySet.add(key));
613614
}
614615
// Get all own property names and symbols.
615-
keys = ObjectGetOwnPropertyNames(obj);
616-
const symbols = ObjectGetOwnPropertySymbols(obj);
617-
if (symbols.length !== 0) {
618-
keys.push(...symbols);
619-
}
616+
keys = ReflectOwnKeys(obj);
620617
for (const key of keys) {
621618
// Ignore the `constructor` property and keys that exist on layers above.
622619
if (key === 'constructor' ||
@@ -660,12 +657,10 @@ function getPrefix(constructor, tag, fallback, size = '') {
660657
// Look up the keys of the object.
661658
function getKeys(value, showHidden) {
662659
let keys;
663-
const symbols = ObjectGetOwnPropertySymbols(value);
664660
if (showHidden) {
665-
keys = ObjectGetOwnPropertyNames(value);
666-
if (symbols.length !== 0)
667-
keys.push(...symbols);
661+
keys = ReflectOwnKeys(value);
668662
} else {
663+
const symbols = ObjectGetOwnPropertySymbols(value);
669664
// This might throw if `value` is a Module Namespace Object from an
670665
// unevaluated module, but we don't want to perform the actual type
671666
// check because it's expensive.

0 commit comments

Comments
 (0)