Skip to content

Commit 016dd0f

Browse files
BridgeARtargos
authored andcommitted
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 <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent b922e77 commit 016dd0f

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

lib/internal/util/inspect.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,7 @@ function formatProxy(ctx, proxy, recurseTimes) {
404404
formatValue(ctx, proxy[1], recurseTimes)
405405
];
406406
ctx.indentationLvl -= 2;
407-
const str = reduceToSingleString(ctx, res, '', ['[', ']']);
408-
return `Proxy ${str}`;
407+
return reduceToSingleString(ctx, res, '', ['Proxy [', ']']);
409408
}
410409

411410
function findTypedConstructor(value) {

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ const expected1 = 'Proxy [ {}, {} ]';
5050
const expected2 = 'Proxy [ Proxy [ {}, {} ], {} ]';
5151
const expected3 = 'Proxy [ Proxy [ Proxy [ {}, {} ], {} ], Proxy [ {}, {} ] ]';
5252
const expected4 = 'Proxy [ Proxy [ {}, {} ], Proxy [ Proxy [ {}, {} ], {} ] ]';
53-
const expected5 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], {} ],' +
54-
' Proxy [ {}, {} ] ],\n Proxy [ Proxy [ {}, {} ]' +
55-
', Proxy [ Proxy [Array], {} ] ] ]';
56-
const expected6 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], Proxy [Array]' +
57-
' ],\n Proxy [ Proxy [Array], Proxy [Array] ] ],\n' +
58-
' Proxy [ Proxy [ Proxy [Array], Proxy [Array] ],\n' +
53+
const expected5 = 'Proxy [\n ' +
54+
'Proxy [ Proxy [ Proxy [Array], {} ], Proxy [ {}, {} ] ],\n' +
55+
' Proxy [ Proxy [ {}, {} ], Proxy [ Proxy [Array], {} ] ] ]';
56+
const expected6 = 'Proxy [\n' +
57+
' Proxy [\n' +
58+
' Proxy [ Proxy [Array], Proxy [Array] ],\n' +
59+
' Proxy [ Proxy [Array], Proxy [Array] ] ],\n' +
60+
' Proxy [\n' +
61+
' Proxy [ Proxy [Array], Proxy [Array] ],\n' +
5962
' Proxy [ Proxy [Array], Proxy [Array] ] ] ]';
6063
assert.strictEqual(
6164
util.inspect(proxy1, { showProxy: true, depth: null }),

0 commit comments

Comments
 (0)