The string to truncate.
The maximum length of the string (including ellipsis).
Optional. The ellipsis string to append. Defaults to "…".
The truncated string with ellipsis if needed.
truncate("Hello world", 8); // Returns: "Hello w…"
truncate("Short", 10); // Returns: "Short"
truncate("Very long string that needs truncation", 15); // Returns: "Very long str…"
truncate("Test", 3, "!!!"); // Returns: "!!!"
Generated using TypeDoc
Truncates a string to a specified length and appends ellipsis if needed.