Skip to content

truncateCore

truncateCore(options): string

Defined in: packages/core/src/string/truncate-core.ts:85

Shared truncate-with-ellipsis algorithm behind truncate (atoms are UTF-16 code units) and @ac-kit/format-monospace’s truncateToWidth (atoms are grapheme clusters) — identical position/word-cutting/ellipsis-budget logic, parameterized only by how one atom’s size is measured.

Callers only call in once they already know the text doesn’t fit maxMeasure — the “already fits” short circuit stays with each caller, since only they know how to compare against the original text cheaply.

TruncateCoreOptions

string