1 | import StreamOutput from './stream';
|
2 | export declare type TableColumn = {
|
3 | key: string;
|
4 | label?: string | (() => string);
|
5 | format: (value: string, row: string) => string;
|
6 | get: (row: any[]) => string;
|
7 | width: number;
|
8 | };
|
9 | export declare type TableOptions = {
|
10 | columns: TableColumn[];
|
11 | colSep: string;
|
12 | after: (row: any[], options: TableOptions) => void;
|
13 | printLine: (row: any[]) => void;
|
14 | printRow: (row: any[]) => void;
|
15 | printHeader: (row: any[]) => void;
|
16 | headerAnsi: any;
|
17 | };
|
18 | /**
|
19 | * Generates a Unicode table and feeds it into configured printer.
|
20 | *
|
21 | * Top-level arguments:
|
22 | *
|
23 | * @arg {Object[]} data - the records to format as a table.
|
24 | * @arg {Object} options - configuration for the table.
|
25 | *
|
26 | * @arg {Object[]} [options.columns] - Options for formatting and finding values for table columns.
|
27 | * @arg {function(string)} [options.headerAnsi] - Zero-width formattter for entire header.
|
28 | * @arg {string} [options.colSep] - Separator between columns.
|
29 | * @arg {function(row, options)} [options.after] - Function called after each row is printed.
|
30 | * @arg {function(string)} [options.printLine] - Function responsible for printing to terminal.
|
31 | * @arg {function(cells)} [options.printHeader] - Function to print header cells as a row.
|
32 | * @arg {function(cells)} [options.printRow] - Function to print cells as a row.
|
33 | *
|
34 | * @arg {function(row)|string} [options.columns[].key] - Path to the value in the row or function to retrieve the pre-formatted value for the cell.
|
35 | * @arg {function(string)} [options.columns[].label] - Header name for column.
|
36 | * @arg {function(string, row)} [options.columns[].format] - Formatter function for column value.
|
37 | * @arg {function(row)} [options.columns[].get] - Function to return a value to be presented in cell without formatting.
|
38 | *
|
39 | */
|
40 | export declare function table(stream: StreamOutput, data: any[], inputOptions?: Partial<TableOptions>): void;
|