Skip to content

Commit cdb0ea5

Browse files
committed
console: remove a leading space between braces
This commit removes a leading space looking unnecessary if the `joinedOutput` of type `Array` is empty on `reduceToSingleString`. e.g) Proxy [ ] -> Proxy [ ] Signed-off-by: Daeyeon Jeong [email protected]
1 parent 9c88fe1 commit cdb0ea5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/internal/util/inspect.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,9 +1939,12 @@ function reduceToSingleString(
19391939
braces[0].length + base.length + 10;
19401940
if (isBelowBreakLength(ctx, output, start, base)) {
19411941
const joinedOutput = join(output, ', ');
1942+
const space = joinedOutput.length > 0 ? ' ' : '';
19421943
if (!joinedOutput.includes('\n')) {
1943-
return `${base ? `${base} ` : ''}${braces[0]} ${joinedOutput}` +
1944-
` ${braces[1]}`;
1944+
return (
1945+
`${base ? `${base} ` : ''}${braces[0]}${space}${joinedOutput}` +
1946+
` ${braces[1]}`
1947+
);
19451948
}
19461949
}
19471950
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ assert.strictEqual(details[1], null);
7070
details = processUtil.getProxyDetails(r.proxy, false);
7171
assert.strictEqual(details, null);
7272

73-
assert.strictEqual(util.inspect(r.proxy), 'Proxy [ ]');
73+
assert.strictEqual(util.inspect(r.proxy), 'Proxy [ ]');
7474
assert.strictEqual(
7575
util.inspect(r, { showProxy: true }),
7676
'{ proxy: Proxy [ null, null ], revoke: [Function (anonymous)] }',

0 commit comments

Comments
 (0)