Skip to content

truncate

truncate(text, maxLength): string

Truncates the given text to at most maxLength characters, adding ”…” if the text was longer.

string

the string to truncate

number

the maximum allowed length (including the ellipsis)

string

the original text if it’s within the limit, otherwise a truncated version ending with ”…”