Skip to content

Commit 9a45c21

Browse files
hellopaorvagg
authored andcommitted
util: use regexp instead of str.replace().join()
PR-URL: #3689 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b14d9c5 commit 9a45c21

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/util.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -575,13 +575,9 @@ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
575575
}
576576
if (str.indexOf('\n') > -1) {
577577
if (array) {
578-
str = str.split('\n').map(function(line) {
579-
return ' ' + line;
580-
}).join('\n').substr(2);
578+
str = str.replace(/\n/g, '\n ');
581579
} else {
582-
str = '\n' + str.split('\n').map(function(line) {
583-
return ' ' + line;
584-
}).join('\n');
580+
str = str.replace(/(^|\n)/g, '\n ');
585581
}
586582
}
587583
} else {

0 commit comments

Comments
 (0)