Dependency-free and configurable tool to shorten (truncate) a string keeping whole words by default.
npm i @fiquu/shorten
import shorten from '@fiquu/shorten';
const short = shorten('Some long string to shorten with many possible words to split into.');
// 'Some long string to shorten with many possible...'
See the documentaion page for more info and options.