traxxx-web/utils/ellipsis.js

12 lines
212 B
JavaScript
Raw Normal View History

2024-03-21 01:54:05 +00:00
export default function ellipsis(text, limit = 50, ellipse = '...') {
if (!text) {
return '';
}
if (text.length > limit) {
return `${text.slice(0, limit - ellipse.length)}${ellipse}`;
}
return text;
}