MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / getColumns

Method getColumns

packages/cli-v3/src/utilities/ink-table.tsx:88–112  ·  view source on GitHub ↗

* Calculates the width of each column by finding * the longest value in a cell of a particular column. * * Returns a list of column names and their widths.

()

Source from the content-addressed store, hash-verified

86 * Returns a list of column names and their widths.
87 */
88 getColumns(): Column<T>[] {
89 const { columns, padding } = this.getConfig();
90
91 const widths: Column<T>[] = columns.map((key) => {
92 const header = String(key).length;
93 /* Get the width of each cell in the column */
94 const data = this.props.data.map((data) => {
95 const value = data[key];
96
97 if (value == undefined || value == null) return 0;
98 return String(value).length;
99 });
100
101 const width = Math.max(...data, header) + padding * 2;
102
103 /* Construct a cell */
104 return {
105 column: key,
106 width: width,
107 key: String(key),
108 };
109 });
110
111 return widths;
112 }
113
114 /**
115 * Returns a (data) row representing the headings.

Callers 1

renderMethod · 0.95

Calls 2

getConfigMethod · 0.95
maxMethod · 0.80

Tested by

no test coverage detected