MCPcopy Create free account
hub / github.com/cli-table/cli-table3 / layoutTable

Function layoutTable

src/layout-manager.js:13–35  ·  view source on GitHub ↗
(table)

Source from the content-addressed store, hash-verified

11 }
12
13 function layoutTable(table) {
14 let alloc = {};
15 table.forEach(function (row, rowIndex) {
16 let col = 0;
17 row.forEach(function (cell) {
18 cell.y = rowIndex;
19 // Avoid erroneous call to next() on first row
20 cell.x = rowIndex ? next(alloc, col) : col;
21 const rowSpan = cell.rowSpan || 1;
22 const colSpan = cell.colSpan || 1;
23 if (rowSpan > 1) {
24 for (let cs = 0; cs < colSpan; cs++) {
25 alloc[cell.x + cs] = rowSpan;
26 }
27 }
28 col = cell.x + colSpan;
29 });
30 Object.keys(alloc).forEach((idx) => {
31 alloc[idx]--;
32 if (alloc[idx] < 1) delete alloc[idx];
33 });
34 });
35 }
36
37 function maxWidth(table) {
38 let mw = 0;

Callers 2

makeTableLayoutFunction · 0.85

Calls 1

nextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…