// Utils
-// Returns number of digits (+1)
-function intChars(n) {
- // TODO dumb:
- if (n < 50) {
- return 3;
- } else if (n < 950) {
- return 4;
- } else if (n < 9950) {
- return 5;
- } else {
- return 6;
- }
-}
-
// Adds spaces and prefix to number
-function leftPad(n, prefix) {
+// maxN is a maximum number we should have space for
+function leftPad(n, prefix, maxN) {
var s = n.toString(),
- nchars = intChars(n),
+ nchars = Math.max(2, String(maxN).length) + 1,
nspaces = nchars - s.length - 1;
- prefix || (prefix = ' ');
-
for (var i = 0; i < nspaces; i++) {
prefix += ' ';
}
prefixChar = '*';
}
- self.print(leftPad(lineno, prefixChar) + ' ' + line);
+ self.print(leftPad(lineno, prefixChar, to) + ' ' + line);
}
self.resume();
});
if (verbose) self.print('Watchers:');
self._watchers.forEach(function(watcher, i) {
- self.print(leftPad(i, ' ') + ': ' + watcher + ' = ' +
+ self.print(leftPad(i, ' ', self._watchers.length - 1) +
+ ': ' + watcher + ' = ' +
JSON.stringify(values[i]));
});