summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-12-12 00:25:32 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-12-16 12:32:58 +0100
commit02b66b5b866bd8398e7d815d3715ba3f94a5cf65 (patch)
treeb14da4f33c59b0a4e94b5c19999564cc13840913 /lib
parent5f4fa0756b6961cf73a224f4307eaba13b9f9d40 (diff)
downloadandroid-node-v8-02b66b5b866bd8398e7d815d3715ba3f94a5cf65.tar.gz
android-node-v8-02b66b5b866bd8398e7d815d3715ba3f94a5cf65.tar.bz2
android-node-v8-02b66b5b866bd8398e7d815d3715ba3f94a5cf65.zip
util: inspect all prototypes
It is currently difficult to distinguish multiple objects from each other because the prototype is not properly inspected. From now on all prototypes will be inspected, even if we do not fully know how they will look like / what their shape really is. PR-URL: https://github.com/nodejs/node/pull/24974 Fixes: https://github.com/nodejs/node/issues/24917 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/util/inspect.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js
index 4e8e4d4730..256a4a8b06 100644
--- a/lib/internal/util/inspect.js
+++ b/lib/internal/util/inspect.js
@@ -322,7 +322,7 @@ function getEmptyFormatArray() {
return [];
}
-function getConstructorName(obj) {
+function getConstructorName(obj, ctx) {
let firstProto;
while (obj) {
const descriptor = Object.getOwnPropertyDescriptor(obj, 'constructor');
@@ -341,10 +341,11 @@ function getConstructorName(obj) {
if (firstProto === null) {
return null;
}
- // TODO(BridgeAR): Improve prototype inspection.
- // We could use inspect on the prototype itself to improve the output.
- return '';
+ return `<${inspect(firstProto, {
+ ...ctx,
+ customInspect: false
+ })}>`;
}
function getPrefix(constructor, tag, fallback) {
@@ -503,7 +504,7 @@ function formatValue(ctx, value, recurseTimes) {
}
if (ctx.stop !== undefined) {
- const name = getConstructorName(value) || value[Symbol.toStringTag];
+ const name = getConstructorName(value, ctx) || value[Symbol.toStringTag];
return ctx.stylize(`[${name || 'Object'}]`, 'special');
}
@@ -547,7 +548,7 @@ function formatValue(ctx, value, recurseTimes) {
function formatRaw(ctx, value, recurseTimes) {
let keys;
- const constructor = getConstructorName(value);
+ const constructor = getConstructorName(value, ctx);
let tag = value[Symbol.toStringTag];
if (typeof tag !== 'string')
tag = '';