Skip to content

Commit c495468

Browse files
committed
url: refactor lib/internal/url.js
* set an identifier for the separator rather than using multiple instances of the same literal * consistent arrow function body formatting
1 parent 80c72c6 commit c495468

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/internal/url.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ URLSearchParams.prototype[Symbol.iterator] = URLSearchParams.prototype.entries;
862862

863863
URLSearchParams.prototype[util.inspect.custom] =
864864
function inspect(recurseTimes, ctx) {
865+
const separator = ', ';
865866
const innerOpts = Object.assign({}, ctx);
866867
if (recurseTimes !== null) {
867868
innerOpts.depth = recurseTimes - 1;
@@ -874,13 +875,14 @@ URLSearchParams.prototype[util.inspect.custom] =
874875
output.push(`${innerInspect(list[i])} => ${innerInspect(list[i + 1])}`);
875876

876877
const colorRe = /\u001b\[\d\d?m/g;
877-
const length = output.reduce((prev, cur) => {
878-
return prev + cur.replace(colorRe, '').length + ', '.length;
879-
}, -', '.length);
878+
const length = output.reduce(
879+
(prev, cur) => prev + cur.replace(colorRe, '').length + separator.length,
880+
-separator.length
881+
);
880882
if (length > ctx.breakLength) {
881883
return `${this.constructor.name} {\n ${output.join(',\n ')} }`;
882884
} else if (output.length) {
883-
return `${this.constructor.name} { ${output.join(', ')} }`;
885+
return `${this.constructor.name} { ${output.join(separator)} }`;
884886
} else {
885887
return `${this.constructor.name} {}`;
886888
}

0 commit comments

Comments
 (0)