| 36 | }; |
| 37 | |
| 38 | const renderRow = (row, columnWidths) => { |
| 39 | let out = tableChars.left; |
| 40 | for (let i = 0; i < row.length; i++) { |
| 41 | const cell = row[i]; |
| 42 | const len = getStringWidth(cell); |
| 43 | const needed = (columnWidths[i] - len); |
| 44 | // round(needed) + ceil(needed) will always add up to the amount |
| 45 | // of spaces we need while also left justifying the output. |
| 46 | out += cell + StringPrototypeRepeat(' ', MathCeil(needed)); |
| 47 | if (i !== row.length - 1) |
| 48 | out += tableChars.middle; |
| 49 | } |
| 50 | out += tableChars.right; |
| 51 | return out; |
| 52 | }; |
| 53 | |
| 54 | const table = (head, columns) => { |
| 55 | const rows = []; |