Skip to content

Commit

Permalink
util: prefer Reflect.ownKeys(…)
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Jan 2, 2021
1 parent 873d21c commit e1cce62
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const {
ObjectPrototypePropertyIsEnumerable,
ObjectSeal,
ObjectSetPrototypeOf,
ReflectOwnKeys,
RegExp,
RegExpPrototypeTest,
RegExpPrototypeToString,
Expand Down Expand Up @@ -612,11 +613,7 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, output) {
keys.forEach((key) => keySet.add(key));
}
// Get all own property names and symbols.
keys = ObjectGetOwnPropertyNames(obj);
const symbols = ObjectGetOwnPropertySymbols(obj);
if (symbols.length !== 0) {
keys.push(...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 @@ -660,12 +657,10 @@ function getPrefix(constructor, tag, fallback, size = '') {
// Look up the keys of the object.
function getKeys(value, showHidden) {
let keys;
const symbols = ObjectGetOwnPropertySymbols(value);
if (showHidden) {
keys = ObjectGetOwnPropertyNames(value);
if (symbols.length !== 0)
keys.push(...symbols);
keys = ReflectOwnKeys(value);
} else {
const symbols = ObjectGetOwnPropertySymbols(value);
// This might throw if `value` is a Module Namespace Object from an
// unevaluated module, but we don't want to perform the actual type
// check because it's expensive.
Expand Down

0 comments on commit e1cce62

Please sign in to comment.