bjira 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/table.js +6 -4
package/package.json
CHANGED
package/src/table.js
CHANGED
|
@@ -53,14 +53,14 @@ class Table {
|
|
|
53
53
|
const lines = [];
|
|
54
54
|
|
|
55
55
|
if (this._columns.find(column => !!column.head)) {
|
|
56
|
-
lines.push(this._columns.map(column => (color.red(this._toWidth(column.head || "", column.width)))).join(" "));
|
|
56
|
+
lines.push(this._columns.map((column, pos, array) => (color.red(this._toWidth(column.head || "", column.width, pos < array.length - 1)))).join(" "));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
for (let row = 0; row < this._rows; ++row) {
|
|
60
60
|
const rowHeight = Math.max(...this._columns.map(column => this._computeRowHeight(column, row)));
|
|
61
61
|
|
|
62
62
|
for (let i = 0; i < rowHeight; ++i) {
|
|
63
|
-
lines.push(this._columns.map(column => this._stylize(column.rows[row], this._toWidth(this._computeLine(column.rows[row], i), column.width))).join(" "));
|
|
63
|
+
lines.push(this._columns.map((column, pos, array) => this._stylize(column.rows[row], this._toWidth(this._computeLine(column.rows[row], i), column.width, pos < array.length - 1))).join(" "));
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -87,7 +87,7 @@ class Table {
|
|
|
87
87
|
return column.rows[row].text.length;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
_toWidth(str, width) {
|
|
90
|
+
_toWidth(str, width, spaces) {
|
|
91
91
|
str = str || "";
|
|
92
92
|
|
|
93
93
|
let strLength = str.length;
|
|
@@ -95,7 +95,9 @@ class Table {
|
|
|
95
95
|
return this._truncate(str, width - 1) + "…";
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
if (spaces) {
|
|
99
|
+
for (let strLength = str.length; strLength < width; ++strLength) str += " ";
|
|
100
|
+
}
|
|
99
101
|
return str;
|
|
100
102
|
}
|
|
101
103
|
|