linegauge
API reference

linegauge/cli-truncate

Every export of linegauge/cli-truncate, with its signature and doc comment: cliTruncate, plus 1 type.

import cliTruncate from 'linegauge/cli-truncate';
import type { Options } from 'linegauge/cli-truncate';

Functions

default

The default export, declared as cliTruncate.

Truncate text to columns terminal columns, as cli-truncate does.

function cliTruncate(text: string, columns: number, options?: Options): string;
ParameterType
textstring
columnsnumber
options (optional)Options

Returns string

Interfaces

Options

cli-truncate's options.

interface Options {
    /** Which end loses characters. Default `'end'`. */
    readonly position?: 'start' | 'middle' | 'end';
    /** A space between the text and the mark. Default `false`. */
    readonly space?: boolean;
    /** Cut at a space within three columns of the break, when there is one. Default `false`. */
    readonly preferTruncationOnSpace?: boolean;
    /** The mark that says something was removed. Default `'…'`. */
    readonly truncationCharacter?: string;
}

On this page