Skip to content

Commit

Permalink
util: prefer Reflect.ownKeys(…)
Browse files Browse the repository at this point in the history
PR-URL: #36740
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
ExE-Boss authored and ruyadorno committed Jan 25, 2021
1 parent 17bdcd9 commit f270417
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const {
ObjectPrototypePropertyIsEnumerable,
ObjectSeal,
ObjectSetPrototypeOf,
ReflectOwnKeys,
RegExp,
RegExpPrototypeTest,
RegExpPrototypeToString,
Expand Down Expand Up @@ -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' ||
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f270417

Please sign in to comment.