UNPKG

@oclif/table

Version:

Display table in terminal

51 lines (50 loc) 2.78 kB
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; /** * Gets the width of the terminal column. * First checks for an override in the OCLIF_TABLE_COLUMN_OVERRIDE environment variable. * If no override is set or the override is 0, returns the actual terminal width from process.stdout.columns. * * It's possible that `process.stdout.columns` is undefined or 0, which is okay. We'll end up using the table's natural width * in that case. If that renders poorly for the user, they can set the OCLIF_TABLE_COLUMN_OVERRIDE environment variable to a * non-zero value. * * @returns {number} The width of the terminal column */ export declare function getColumnWidth(): number; /** * Determines the configured width based on the provided width value. * If no width is provided, it returns the width of the current terminal. * - It's possible that `process.stdout.columns` is undefined, which is okay. We'll end up using the table's natural width. * 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 | 'none' | 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;