Added a function to truncate a string with an ellipsis
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user