From 7910b025a26839483f4ae1d50a60d00c8d32f81b Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 1 May 2019 22:21:00 +0200 Subject: util: inspect constructor closer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds an extra check to `util.inspect` to closer inspect object constructors in case there's not much other information about the constructor. PR-URL: https://github.com/nodejs/node/pull/27522 Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso Reviewed-By: Rich Trott Reviewed-By: Yongsheng Zhang --- lib/internal/util/inspect.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/internal/util/inspect.js') diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 22dec67330..21b9921dbe 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -28,6 +28,7 @@ const { kPending, kRejected, previewEntries, + getConstructorName: internalGetConstructorName, propertyFilter: { ALL_PROPERTIES, ONLY_ENUMERABLE @@ -349,6 +350,7 @@ function getEmptyFormatArray() { function getConstructorName(obj, ctx) { let firstProto; + const tmp = obj; while (obj) { const descriptor = Object.getOwnPropertyDescriptor(obj, 'constructor'); if (descriptor !== undefined && @@ -367,7 +369,7 @@ function getConstructorName(obj, ctx) { return null; } - return `<${inspect(firstProto, { + return `${internalGetConstructorName(tmp)} <${inspect(firstProto, { ...ctx, customInspect: false })}>`; -- cgit v1.2.3