UNPKG
@amxdev/truncate-text
Version:
latest (1.0.0)
1.0.0
Truncate long text to a maximum length with ellipsis.
@amxdev/truncate-text
/
src
/
index.ts
3 lines
•
150 B
text/typescript
View Raw
1
2
3
export
function
truncateText
(
text
:
string
,
maxLength
:
number
):
string
{
return
text.
length
<= maxLength ? text : text.
slice
(
0
, maxLength) +
'...'
; }