Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: prefer Reflect.ownKeys(…) in util.inspect(…) #36740

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
util: prefer Reflect.ownKeys(…)
PR-URL: #36740
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
ExE-Boss authored and aduh95 committed Jan 20, 2021
commit e9944e9a389ed8f0c4ce952cc56d068b0839863d
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