truncateToWidth
truncateToWidth(
text,maxWidth,options?):string
Defined in: truncate-to-width.ts:20
Truncates text to at most maxWidth columns, counting wide characters (CJK
ideographs, fullwidth characters, emoji) as two columns and combining marks
as zero columns.
maxWidth counts monospace columns, not UTF-16 code units or code points — a
surrogate pair can be split across the cut. Use truncate for a
code-unit-based cut.
Parameters
Section titled “Parameters”string
The input string to be truncated.
maxWidth
Section titled “maxWidth”number
The maximum allowed width of the string including the ellipsis.
options?
Section titled “options?”TruncateOptions
Options to customize the ellipsis behavior.
Returns
Section titled “Returns”string
The truncated string with ellipsis if needed.