diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index dc0a1dcb279ff7..06578cb56ef6a1 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -423,8 +423,7 @@ function formatProxy(ctx, proxy, recurseTimes) { formatValue(ctx, proxy[1], recurseTimes) ]; ctx.indentationLvl -= 2; - const str = reduceToSingleString(ctx, res, '', ['[', ']']); - return `Proxy ${str}`; + return reduceToSingleString(ctx, res, '', ['Proxy [', ']']); } function findTypedConstructor(value) { diff --git a/test/parallel/test-util-inspect-proxy.js b/test/parallel/test-util-inspect-proxy.js index 9aaa8fb13eeb71..97d2006408acdc 100644 --- a/test/parallel/test-util-inspect-proxy.js +++ b/test/parallel/test-util-inspect-proxy.js @@ -49,7 +49,8 @@ assert.strictEqual(handler, details[1]); assert.strictEqual( util.inspect(proxyObj, opts), - 'Proxy [ [ 1, 2, 3 ],\n' + + 'Proxy [\n' + + ' [ 1, 2, 3 ],\n' + ' { getPrototypeOf: [Function: getPrototypeOf],\n' + ' setPrototypeOf: [Function: setPrototypeOf],\n' + ' isExtensible: [Function: isExtensible],\n' + @@ -86,12 +87,15 @@ const expected1 = 'Proxy [ {}, {} ]'; const expected2 = 'Proxy [ Proxy [ {}, {} ], {} ]'; const expected3 = 'Proxy [ Proxy [ Proxy [ {}, {} ], {} ], Proxy [ {}, {} ] ]'; const expected4 = 'Proxy [ Proxy [ {}, {} ], Proxy [ Proxy [ {}, {} ], {} ] ]'; -const expected5 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], {} ],' + - ' Proxy [ {}, {} ] ],\n Proxy [ Proxy [ {}, {} ]' + - ', Proxy [ Proxy [Array], {} ] ] ]'; -const expected6 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], Proxy [Array]' + - ' ],\n Proxy [ Proxy [Array], Proxy [Array] ] ],\n' + - ' Proxy [ Proxy [ Proxy [Array], Proxy [Array] ],\n' + +const expected5 = 'Proxy [\n ' + + 'Proxy [ Proxy [ Proxy [Array], {} ], Proxy [ {}, {} ] ],\n' + + ' Proxy [ Proxy [ {}, {} ], Proxy [ Proxy [Array], {} ] ] ]'; +const expected6 = 'Proxy [\n' + + ' Proxy [\n' + + ' Proxy [ Proxy [Array], Proxy [Array] ],\n' + + ' Proxy [ Proxy [Array], Proxy [Array] ] ],\n' + + ' Proxy [\n' + + ' Proxy [ Proxy [Array], Proxy [Array] ],\n' + ' Proxy [ Proxy [Array], Proxy [Array] ] ] ]'; assert.strictEqual( util.inspect(proxy1, { showProxy: true, depth: null }),