diff options
-rw-r--r-- | lib/util.js | 8 | ||||
-rw-r--r-- | test/parallel/test-util-inspect.js | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/util.js b/lib/util.js index 07fbe15f38..590a3b4903 100644 --- a/lib/util.js +++ b/lib/util.js @@ -594,11 +594,9 @@ function formatValue(ctx, value, recurseTimes, ln) { return ctx.stylize('[Circular]', 'special'); if (recurseTimes != null) { - if (recurseTimes < 0) { - if (Array.isArray(value)) - return ctx.stylize('[Array]', 'special'); - return ctx.stylize('[Object]', 'special'); - } + if (recurseTimes < 0) + return ctx.stylize(`[${constructor ? constructor.name : 'Object'}]`, + 'special'); recurseTimes -= 1; } diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 70f7c4d431..02e35ec9e8 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -994,6 +994,10 @@ if (typeof Symbol !== 'undefined') { 'MapSubclass { \'foo\' => 42 }'); assert.strictEqual(util.inspect(new PromiseSubclass(() => {})), 'PromiseSubclass { <pending> }'); + assert.strictEqual( + util.inspect({ a: { b: new ArraySubclass([1, [2], 3]) } }, { depth: 1 }), + '{ a: { b: [ArraySubclass] } }' + ); } // Empty and circular before depth |