OfficeSystem/utils/textSolve/truncateText.js

9 lines
238 B
JavaScript
Raw Normal View History

2025-11-12 15:15:04 +08:00
export const truncateText = (text, maxLength = 30, suffix = '...')=> {
if (!text || typeof text !== 'string') return ''
if (text.length <= maxLength) {
return text
}
return text.substring(0, maxLength) + suffix
}