Skip to content

Commit bb9c1e7

Browse files
committed
console: remove spaces for the output is empty
This commit removes extra spaces looking unnecessary if the `joinedOutput` of type `Array` is empty on `reduceToSingleString`. e.g) Proxy [ ] -> Proxy [] Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com
1 parent 9c88fe1 commit bb9c1e7

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+
`${space}${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)