/string-truncate

Truncate strings

Primary LanguageTypeScriptMIT LicenseMIT

🌙 @ricardojrmcom/string-truncate

Truncate strings

build license

author

lang version size




Install

npm install @ricardojrmcom/string-truncate

yarn add @ricardojrmcom/string-truncate

Usage

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"



License

MIT © Ricardo <l1b3r_-> Mota (@ricardojrmcom)

Bootstrapped with 🟪@ricardojrmcom/nova