8 lines
223 B
TypeScript
8 lines
223 B
TypeScript
export const shortenText = (value: string, maxLen: number) => {
|
|
const chars = Array.from(value);
|
|
if (chars.length <= maxLen) {
|
|
return value;
|
|
}
|
|
return `${chars.slice(0, Math.max(0, maxLen - 1)).join("")}…`;
|
|
};
|