truncate
truncate(
text,maxLength,options?):string
Defined in: packages/core/src/string/truncate.ts:42
Truncates text to at most maxLength UTF-16 code units, counting each code
unit as one unit of length.
This is a simple truncation that does not consider grapheme clusters or wide
characters. Use @ac-kit/format-monospace’s truncateToWidth for truncation
based on visible width in monospace fonts.
Parameters
Section titled “Parameters”string
The input string to be truncated.
maxLength
Section titled “maxLength”number
The maximum allowed length of the string including the ellipsis.
options?
Section titled “options?”Options to customize the ellipsis behavior.
Returns
Section titled “Returns”string
The truncated string with ellipsis if needed.