util: remove erroneous whitespace · nodejs/node@38bc5fb · GitHub
Skip to content

Commit 38bc5fb

Browse files
BridgeARMylesBorins
authored andcommitted
util: remove erroneous whitespace
When inspecting nested objects some times a whitespace was added at the end of a line. This fixes this erroneous space. Besides that the `breakLength` was not followed if a single property was longer than the breakLength. It will now break a single property into the key and value in such cases. PR-URL: #20802 Refs: #20253 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 5ce85a7 commit 38bc5fb

4 files changed

Lines changed: 56 additions & 52 deletions

File tree

lib/util.js

Lines changed: 42 additions & 40 deletions

test/parallel/test-util-format.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ assert.strictEqual(
126126
util.format('%o', obj),
127127
'{ foo: \'bar\',\n' +
128128
' foobar: 1,\n' +
129-
' func: \n' +
129+
' func:\n' +
130130
' { [Function: func]\n' +
131131
' [length]: 0,\n' +
132132
' [name]: \'func\',\n' +
@@ -135,8 +135,8 @@ assert.strictEqual(
135135
util.format('%o', nestedObj2),
136136
'{ foo: \'bar\',\n' +
137137
' foobar: 1,\n' +
138-
' func: \n' +
139-
' [ { a: \n' +
138+
' func:\n' +
139+
' [ { a:\n' +
140140
' { [Function: a]\n' +
141141
' [length]: 0,\n' +
142142
' [name]: \'a\',\n' +
@@ -145,9 +145,9 @@ assert.strictEqual(
145145
assert.strictEqual(
146146
util.format('%o', nestedObj),
147147
'{ foo: \'bar\',\n' +
148-
' foobar: \n' +
148+
' foobar:\n' +
149149
' { foo: \'bar\',\n' +
150-
' func: \n' +
150+
' func:\n' +
151151
' { [Function: func]\n' +
152152
' [length]: 0,\n' +
153153
' [name]: \'func\',\n' +
@@ -156,14 +156,14 @@ assert.strictEqual(
156156
util.format('%o %o', obj, obj),
157157
'{ foo: \'bar\',\n' +
158158
' foobar: 1,\n' +
159-
' func: \n' +
159+
' func:\n' +
160160
' { [Function: func]\n' +
161161
' [length]: 0,\n' +
162162
' [name]: \'func\',\n' +
163163
' [prototype]: func { [constructor]: [Circular] } } }' +
164164
' { foo: \'bar\',\n' +
165165
' foobar: 1,\n' +
166-
' func: \n' +
166+
' func:\n' +
167167
' { [Function: func]\n' +
168168
' [length]: 0,\n' +
169169
' [name]: \'func\',\n' +
@@ -172,7 +172,7 @@ assert.strictEqual(
172172
util.format('%o %o', obj),
173173
'{ foo: \'bar\',\n' +
174174
' foobar: 1,\n' +
175-
' func: \n' +
175+
' func:\n' +
176176
' { [Function: func]\n' +
177177
' [length]: 0,\n' +
178178
' [name]: \'func\',\n' +

test/parallel/test-util-inspect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ util.inspect(process);
12371237

12381238
let out = util.inspect(o, { compact: true, depth: 5, breakLength: 80 });
12391239
let expect = [
1240-
'{ a: ',
1240+
'{ a:',
12411241
' [ 1,',
12421242
' 2,',
12431243
" [ [ 'Lorem ipsum dolor\\nsit amet,\\tconsectetur adipiscing elit, " +

test/parallel/test-whatwg-url-inspect.js

Lines changed: 5 additions & 3 deletions

0 commit comments

Comments
 (0)