6
common/resources/client/utils/string/truncate-string.ts
Executable file
6
common/resources/client/utils/string/truncate-string.ts
Executable file
@@ -0,0 +1,6 @@
|
||||
export function truncateString(str: string, length: number, end = '...') {
|
||||
if (length == null || length >= str.length) {
|
||||
return str;
|
||||
}
|
||||
return str.slice(0, Math.max(0, length - end.length)) + end;
|
||||
}
|
||||
Reference in New Issue
Block a user