TelegramPWA/src/util/trimText.ts
2022-02-02 22:52:36 +01:00

8 lines
210 B
TypeScript

export default function trimText<T extends string | undefined>(text: T, length?: number) {
if (!text || !length || text.length <= length) {
return text;
}
return `${text.substring(0, length)}...`;
}