Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (19 sloc) 899 Bytes

trunky - Basic truncation and string tools

build status


npm install trunky


var truncate = require('trunky').truncateWithEllipsis;

truncate('Hello world', 8); // Hello…
truncate('<b>Hello</b> world', 8); // Hello…

Note: the unicode character (\u2026) is used by default. If your application does not support unicode or you would prefer a different ellipsis character, truncate() takes an optional third argument which is the string to use:

truncate('Hello world', 8, '...'); // Hello...
truncate('Hello world', 8, ' etc.'); // Hello etc.


Paul Serby follow me on twitter


Licenced under the New BSD License