8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f1b18ba commit 4433ecbCopy full SHA for 4433ecb
lib/internal/cli_table.js
@@ -51,31 +51,28 @@ const table = (head, columns) => {
51
for (var i = 0; i < head.length; i++) {
52
const column = columns[i];
53
for (var j = 0; j < longestColumn; j++) {
54
- if (!rows[j])
+ if (rows[j] === undefined)
55
rows[j] = [];
56
- const v = rows[j][i] = HasOwnProperty(column, j) ? column[j] : '';
+ const value = rows[j][i] = HasOwnProperty(column, j) ? column[j] : '';
57
const width = columnWidths[i] || 0;
58
- const counted = countSymbols(v);
+ const counted = countSymbols(value);
59
columnWidths[i] = Math.max(width, counted);
60
}
61
62
63
const divider = columnWidths.map((i) =>
64
tableChars.middleMiddle.repeat(i + 2));
65
66
- const tl = tableChars.topLeft;
67
- const tr = tableChars.topRight;
68
- const lm = tableChars.leftMiddle;
69
- let result = `${tl}${divider.join(tableChars.topMiddle)}${tr}
70
-${renderRow(head, columnWidths)}
71
-${lm}${divider.join(tableChars.rowMiddle)}${tableChars.rightMiddle}
72
-`;
+ let result = `${tableChars.topLeft}${divider.join(tableChars.topMiddle)}` +
+ `${tableChars.topRight}\n${renderRow(head, columnWidths)}\n` +
+ `${tableChars.leftMiddle}${divider.join(tableChars.rowMiddle)}` +
+ `${tableChars.rightMiddle}\n`;
73
74
for (const row of rows)
75
result += `${renderRow(row, columnWidths)}\n`;
76
77
- result += `${tableChars.bottomLeft}${
78
- divider.join(tableChars.bottomMiddle)}${tableChars.bottomRight}`;
+ result += `${tableChars.bottomLeft}${divider.join(tableChars.bottomMiddle)}` +
+ tableChars.bottomRight;
79
80
return result;
81
};