(str: string, max: number = 0)
| 11 | * @returns string Encoded |
| 12 | */ |
| 13 | export function truncate(str: string, max: number = 0): string { |
| 14 | if (typeof str !== 'string' || max === 0) { |
| 15 | return str; |
| 16 | } |
| 17 | return str.length <= max ? str : `${str.slice(0, max)}...`; |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * This is basically just `trim_line` from |
no test coverage detected