Skip to main content
zerotal

Documentation


Documentation / zerotal / logger / renderTable

Function: renderTable()

renderTable(data, indent?): string[]

Defined in: packages/core/src/logger/renderTable.ts:37

Render data as the lines of a box-drawn table, without a trailing newline.

An array of objects becomes a column per key, in the order the first row introduces them, with a header. A single object becomes two columns of key and value. Numeric columns are right-aligned so digits line up.

Parameters

data

TableData

Rows to render.

indent?

number = 2

Spaces before each line, to sit the table under its message.

Returns

string[]

One string per line; empty when there is nothing to show.

Example

renderTable([{ page: "home", ms: 12 }, { page: "about", ms: 4 }]).join("\n");