Skip to content

gorangajic/smart-ellipsis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smart-ellipsis

cut text and add ellipsis/tail without quirks

Build Status

When using something like substr and adding ... you get all kind of quirks and this module handle that quirks

install

npm install smart-ellipsis

usage

const smartEllipsis = require('smart-ellipsis');

smartEllipsis(text, maxLength);

examples

it will not cut in half

smartEllipsis('hello world', 7) // 'hello...'

it will remove extra . and space

smartEllipsis('hello world. what\'s up?', 12) // 'hello world...'

it will remove extra ,

smartEllipsis('hello world, what\'s up?', 11) // 'hello world...'

it will remove extra \n

smartEllipsis('hello world\n what\'s up?', 11) // 'hello world...'

it will remove extra \r\n

smartEllipsis('hello world\r\n what\'s up?', 11) // 'hello world...'

it will remove extra ?

smartEllipsis('hello world? what\'s up?', 11) // 'hello world...'

it will remove !

smartEllipsis('hello world! what\'s up?', 11) // 'hello world...'

About

cut text and add ellipsis/tail without quirks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published