Files
DocsGPT/frontend/src/utils/stringUtils.ts
2024-11-27 16:54:05 +05:30

5 lines
157 B
TypeScript

export function truncate(str: string, n: number) {
// slices long strings and ends with ...
return str.length > n ? str.slice(0, n - 1) + '...' : str;
}