Added a function to truncate a string with an ellipsis

This commit is contained in:
Matt Aitken
2023-06-21 17:53:56 +01:00
parent 8bba30e290
commit 21d7ff2f74
2 changed files with 4 additions and 0 deletions
+1
View File
@@ -1,2 +1,3 @@
export * from "./json";
export * from "./omit";
export * from "./properties";
@@ -0,0 +1,3 @@
export function truncate(str: string, maxLength: number) {
return str.length > maxLength ? str.slice(0, maxLength - 1) + "…" : str;
}