fix breakpoint prefixing in list()

pull/22966/head
Fedor Indutny 2011-09-17 15:38:06 +07:00 committed by Ryan Dahl
parent c8ffbcd9f1
commit 292e2ea5ad
1 changed files with 9 additions and 5 deletions

View File

@ -922,13 +922,17 @@ function intChars(n) {
// Adds spaces and prefix to number // Adds spaces and prefix to number
function leftPad(n, prefix) { function leftPad(n, prefix) {
var s = n.toString(); var s = n.toString(),
var nchars = intChars(n); nchars = intChars(n),
var nspaces = nchars - s.length; nspaces = nchars - s.length - 1;
prefix || (prefix = ' ');
for (var i = 0; i < nspaces; i++) { for (var i = 0; i < nspaces; i++) {
s = (prefix || ' ') + s; prefix += ' ';
} }
return s;
return prefix + s;
} }