Browse Source

util: use regexp instead of str.replace().join()

PR-URL: https://github.com/nodejs/node/pull/3689
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
process-exit-stdio-flushing
qinjia 9 years ago
committed by James M Snell
parent
commit
02a44e0bfd
  1. 8
      lib/util.js

8
lib/util.js

@ -575,13 +575,9 @@ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
}
if (str.indexOf('\n') > -1) {
if (array) {
str = str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n').substr(2);
str = str.replace(/\n/g, '\n ');
} else {
str = '\n' + str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n');
str = str.replace(/(^|\n)/g, '\n ');
}
}
} else {

Loading…
Cancel
Save