4 lines
159 B
TypeScript
4 lines
159 B
TypeScript
export function truncate(str: string, maxLength: number = 100): string {
|
|
if (str.length <= maxLength) return str;
|
|
return str.slice(0, maxLength) + '...';
|
|
} |