MCPcopy Create free account
hub / github.com/nodejs/node / renderRow

Function renderRow

lib/internal/cli_table.js:38–52  ·  view source on GitHub ↗
(row, columnWidths)

Source from the content-addressed store, hash-verified

36};
37
38const 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
54const table = (head, columns) => {
55 const rows = [];

Callers 1

tableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected