Truncates a string to a specified length and adds an ellipsis if truncated
The string to truncate
Maximum length of the string (including ellipsis)
The ellipsis string to append (default: '...')
The truncated string
truncate('Hello World', 8); // 'Hello...'truncate('Hello World', 20); // 'Hello World'truncate('Hello World', 8, '…'); // 'Hello …' Copy
truncate('Hello World', 8); // 'Hello...'truncate('Hello World', 20); // 'Hello World'truncate('Hello World', 8, '…'); // 'Hello …'
Truncates a string to a specified length and adds an ellipsis if truncated