Bun

interface

SliceAnsiOptions

interface SliceAnsiOptions

  • ambiguousIsNarrow?: boolean

    Count characters with East Asian Width "Ambiguous" as 1 column (narrow) instead of 2 (wide). Affects Greek, Cyrillic, some symbols, etc. that render wide in CJK-encoded terminals but narrow in Western ones.

    Matches the option of the same name in stringWidth and wrapAnsi.

  • ellipsis?: string

    If set, and content was cut at either edge of the requested range, insert this string at the cut edge(s). The ellipsis is counted against the visible-width budget and is emitted inside any active SGR styles (color, bold, etc.) so it inherits them, but outside any active OSC 8 hyperlink.

    This turns sliceAnsi into a drop-in cli-truncate replacement:

    • truncate-end: sliceAnsi(str, 0, max, { ellipsis: "\u2026" })
    • truncate-start: sliceAnsi(str, -max, undefined, { ellipsis: "\u2026" })