Skip to main content

truncate

Callable

  • truncate(text: string, width: number, options?: Options): string

  • Truncate a string to a desired terminal width while preserving ANSI escape codes, Unicode surrogate pairs, and fullwidth characters. Based on cli-truncate.

    import { truncate } from '@boost/terminal';

    const text = truncate(aStringThatMayContainAnsi, 10, { position: 'middle' });