TelegramPWA/src/util/trimText.ts
Alexander Zinchuk 3afcde3217 Initial commit
2021-04-09 14:11:51 +03:00

10 lines
237 B
TypeScript

const DEFAULT_MAX_TEXT_LENGTH = 30;
export default function trimText(text: string | undefined, length = DEFAULT_MAX_TEXT_LENGTH) {
if (!text || text.length <= length) {
return text;
}
return `${text.substr(0, length)}...`;
}