Skip to content

Commit f74c82d

Browse files
committed
[Fix] when truncating a deep array, note it as [Array] instead of just [Object]
This also matches `util.inspect`.
1 parent 81ebdd4 commit f74c82d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
5959
var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
6060
if (typeof depth === 'undefined') { depth = 0; }
6161
if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
62-
return '[Object]';
62+
return isArray(obj) ? '[Array]' : '[Object]';
6363
}
6464

6565
if (typeof seen === 'undefined') {

test/deep.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ var test = require('tape');
44
test('deep', function (t) {
55
t.plan(2);
66
var obj = [[[[[[500]]]]]];
7-
t.equal(inspect(obj), '[ [ [ [ [ [Object] ] ] ] ] ]');
8-
t.equal(inspect(obj, { depth: 2 }), '[ [ [Object] ] ]');
7+
t.equal(inspect(obj), '[ [ [ [ [ [Array] ] ] ] ] ]');
8+
t.equal(inspect(obj, { depth: 2 }), '[ [ [Array] ] ]');
99
});

0 commit comments

Comments
 (0)