summaryrefslogtreecommitdiff
path: root/lib/internal/util/inspect.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-05-01 22:21:00 +0200
committerZYSzys <zyszys98@gmail.com>2019-05-04 23:45:47 +0800
commit7910b025a26839483f4ae1d50a60d00c8d32f81b (patch)
tree6392659347e456a7ebaf68af3dc4ca1f90920b94 /lib/internal/util/inspect.js
parenteda4d3c59e02769a99cb58c369674a8f8f25974c (diff)
downloadandroid-node-v8-7910b025a26839483f4ae1d50a60d00c8d32f81b.tar.gz
android-node-v8-7910b025a26839483f4ae1d50a60d00c8d32f81b.tar.bz2
android-node-v8-7910b025a26839483f4ae1d50a60d00c8d32f81b.zip
util: inspect constructor closer
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 <anna@addaleax.net> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Diffstat (limited to 'lib/internal/util/inspect.js')
-rw-r--r--lib/internal/util/inspect.js4
1 files changed, 3 insertions, 1 deletions
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
})}>`;