Skip to content

Commit 4bfc06f

Browse files
committed
util: improve proxy inspection
This makes sure the brace is actually handled as any other brace. It was handled differently so far than any other brace and that had an impact on how the output would be formatted. PR-URL: #26919 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 3cf1ffe commit 4bfc06f

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

lib/internal/util/inspect.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,7 @@ function formatProxy(ctx, proxy, recurseTimes) {
423423
formatValue(ctx, proxy[1], recurseTimes)
424424
];
425425
ctx.indentationLvl -= 2;
426-
const str = reduceToSingleString(ctx, res, '', ['[', ']']);
427-
return `Proxy ${str}`;
426+
return reduceToSingleString(ctx, res, '', ['Proxy [', ']']);
428427
}
429428

430429
function findTypedConstructor(value) {

test/parallel/test-util-inspect-proxy.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ assert.strictEqual(handler, details[1]);
4949

5050
assert.strictEqual(
5151
util.inspect(proxyObj, opts),
52-
'Proxy [ [ 1, 2, 3 ],\n' +
52+
'Proxy [\n' +
53+
' [ 1, 2, 3 ],\n' +
5354
' { getPrototypeOf: [Function: getPrototypeOf],\n' +
5455
' setPrototypeOf: [Function: setPrototypeOf],\n' +
5556
' isExtensible: [Function: isExtensible],\n' +
@@ -86,12 +87,15 @@ const expected1 = 'Proxy [ {}, {} ]';
8687
const expected2 = 'Proxy [ Proxy [ {}, {} ], {} ]';
8788
const expected3 = 'Proxy [ Proxy [ Proxy [ {}, {} ], {} ], Proxy [ {}, {} ] ]';
8889
const expected4 = 'Proxy [ Proxy [ {}, {} ], Proxy [ Proxy [ {}, {} ], {} ] ]';
89-
const expected5 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], {} ],' +
90-
' Proxy [ {}, {} ] ],\n Proxy [ Proxy [ {}, {} ]' +
91-
', Proxy [ Proxy [Array], {} ] ] ]';
92-
const expected6 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], Proxy [Array]' +
93-
' ],\n Proxy [ Proxy [Array], Proxy [Array] ] ],\n' +
94-
' Proxy [ Proxy [ Proxy [Array], Proxy [Array] ],\n' +
90+
const expected5 = 'Proxy [\n ' +
91+
'Proxy [ Proxy [ Proxy [Array], {} ], Proxy [ {}, {} ] ],\n' +
92+
' Proxy [ Proxy [ {}, {} ], Proxy [ Proxy [Array], {} ] ] ]';
93+
const expected6 = 'Proxy [\n' +
94+
' Proxy [\n' +
95+
' Proxy [ Proxy [Array], Proxy [Array] ],\n' +
96+
' Proxy [ Proxy [Array], Proxy [Array] ] ],\n' +
97+
' Proxy [\n' +
98+
' Proxy [ Proxy [Array], Proxy [Array] ],\n' +
9599
' Proxy [ Proxy [Array], Proxy [Array] ] ] ]';
96100
assert.strictEqual(
97101
util.inspect(proxy1, { showProxy: true, depth: null }),

0 commit comments

Comments
 (0)