From f2704170a3af3c3c2e259ed9742dcb0278ed974f Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Sat, 2 Jan 2021 15:30:00 +0100 Subject: [PATCH] =?UTF-8?q?util:=20prefer=C2=A0`Reflect.ownKeys(=E2=80=A6)?= =?UTF-8?q?`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/36740 Reviewed-By: Antoine du Hamel --- lib/internal/util/inspect.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index b20ce167f9da44..c40083a1ad497b 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -43,6 +43,7 @@ const { ObjectPrototypePropertyIsEnumerable, ObjectSeal, ObjectSetPrototypeOf, + ReflectOwnKeys, RegExp, RegExpPrototypeTest, RegExpPrototypeToString, @@ -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' || @@ -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