npm install @ricardojrmcom/string-truncate
yarn add @ricardojrmcom/string-truncate
Truncates string to fit within given length with appended ellipsis. Option to keep last word.
import { stringTruncate } from '@ricardojrmcom/string-truncate'
stringTruncate('Lorem ipsum dolor sit amet', 20);
-> "Lorem ipsum dolor..."
stringTruncate('Lorem ipsum dolor sit amet', 20, true);
-> "Lorem ipsum ... amet"
MIT © Ricardo <l1b3r_-> Mota (@ricardojrmcom)
Bootstrapped with 🟪@ricardojrmcom/nova