Skip to content

Commit d676324

Browse files
ExE-Bossruyadorno
authored andcommitted
util: prefer Reflect.ownKeys(…)
PR-URL: #36740 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 4cd471e commit d676324

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎lib/internal/util/inspect.js‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const {
4343
ObjectPrototypePropertyIsEnumerable,
4444
ObjectSeal,
4545
ObjectSetPrototypeOf,
46+
ReflectOwnKeys,
4647
RegExp,
4748
RegExpPrototypeTest,
4849
RegExpPrototypeToString,
@@ -615,11 +616,7 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, output) {
615616
ArrayPrototypeForEach(keys,(key)=>keySet.add(key));
616617
}
617618
// Get all own property names and symbols.
618-
keys=ObjectGetOwnPropertyNames(obj);
619-
constsymbols=ObjectGetOwnPropertySymbols(obj);
620-
if(symbols.length!==0){
621-
ArrayPrototypePush(keys, ...symbols);
622-
}
619+
keys=ReflectOwnKeys(obj);
623620
for(constkeyofkeys){
624621
// Ignore the `constructor` property and keys that exist on layers above.
625622
if(key==='constructor'||
@@ -667,7 +664,7 @@ function getKeys(value, showHidden) {
667664
if(showHidden){
668665
keys=ObjectGetOwnPropertyNames(value);
669666
if(symbols.length!==0)
670-
keys.push(...symbols);
667+
ArrayPrototypePush(keys,...symbols);
671668
}else{
672669
// This might throw if `value` is a Module Namespace Object from an
673670
// unevaluated module, but we don't want to perform the actual type

0 commit comments

Comments
 (0)