UNPKG

cspell

Version:

A Spelling Checker for Code!

41 lines 1.51 kB
export type RowTextFn = (maxWidth: number | undefined) => string; export type TableCell = string | RowTextFn; export type TableRow = TableCell[] | Record<string, TableCell>; export type TableHeaderColumnFieldTitle = [field: string, title: string]; export type TableHeader = string[] | TableHeaderColumnFieldTitle[]; export type TextDecorator = (t: string, columnIndex: number) => string; export interface MaxColumnWidths { /** * [field name or column index]: number of characters */ [column: string | number]: number | undefined; } export interface Table { /** * The header of the table. * Can be an array of strings or an array of tuples with field name and title. */ header: TableHeader; /** * The rows of the table. * Can be an array of arrays or an array of objects with field names as keys. */ rows: TableRow[]; /** * The width of the terminal, used to adjust column widths. */ terminalWidth?: number; /** * The deliminator used to separate columns in the table. * Defaults to ' | ' if not provided. */ deliminator?: string; /** * The maximum widths for each column. * If provided, it will override the calculated widths. */ maxColumnWidths?: MaxColumnWidths; } export declare function tableToLines(table: Table, deliminator?: string): string[]; export declare function decorateRowWith(row: string[], ...decorators: TextDecorator[]): string[]; //# sourceMappingURL=table.d.ts.map