Text to truncate.
Maximum length of the returned string, including the ellipsis.
OptionalbyWords?: booleanWhen true, truncates at the last full word instead of cutting mid-word. Default is false.
Optionalellipsis?: stringString appended when the text is truncated. Default is '...'.
The truncated string, or the original string unchanged if it's already within maxLength.
Shortens text to a maximum length, appending an ellipsis when truncation happens.
maxLengthincludes the ellipsis itself.