@oclif/table
Version:
Display table in terminal
38 lines (37 loc) • 2.02 kB
TypeScript
import { Column, Config, Percentage, Sort } from './types.js';
/**
* Intersperses a list of elements with another element.
*
* @example
* ```js
* intersperse(() => 'foo', [1, 2, 3]) // => [1, 'foo', 2, 'foo', 3]
* ```
*/
export declare function intersperse<T, I>(intersperser: (index: number) => I, elements: T[]): (T | I)[];
export declare function sortData<T extends Record<string, unknown>>(data: T[], sort?: Sort<T> | undefined): T[];
export declare function allKeysInCollection<T extends Record<string, unknown>>(data: T[]): (keyof T)[];
export declare function determineWidthOfWrappedText(text: string): number;
/**
* Determines the configured width based on the provided width value.
* If no width is provided, it returns the width of the current terminal.
* If the provided width is a percentage, it calculates the width based on the percentage of the terminal width.
* If the provided width is a number, it returns the provided width.
* If the calculated width is greater than the terminal width, it returns the terminal width.
*
* @param providedWidth - The width value provided.
* @returns The determined configured width.
*/
export declare function determineConfiguredWidth(providedWidth: number | Percentage | undefined, columns?: number): number;
export declare function getColumns<T extends Record<string, unknown>>(config: Config<T>, headings: Partial<T>): Column<T>[];
export declare function getHeadings<T extends Record<string, unknown>>(config: Config<T>): Partial<T>;
export declare function maybeStripAnsi<T extends Record<string, unknown>[]>(data: T, noStyle: boolean): T;
/**
* Determines whether the plain text table should be used.
*
* If the OCLIF_TABLE_SKIP_CI_CHECK environment variable is set to a truthy value, the CI check will be skipped.
*
* If the CI environment variable is set, the plain text table will be used.
*
* @returns {boolean} True if the plain text table should be used, false otherwise.
*/
export declare function shouldUsePlainTable(): boolean;