truncate

Truncate text and keep urls safe

Truncate

Truncate text and keeps urls safe.

Install the module with: npm install truncate

// Browser 
String.truncate("1234 http://google.com hey :)", 2) === "12..."
// NodeJS 
> truncate = require('truncate');
> truncate("1234 http://google.com hey :)", 4);
"1234..."
> truncate("1234 http://google.com hey :)", 4, {ellipsis:null}); // or ellipsis:'' 
"1234"
> truncate("1234 http://google.com hey :)", 6);
"1234 http://google.com..."
> truncate("1234 http://google.com hey :)", 100);
"1234 http://google.com hey :)"

v1.0.3 - Add repository homepage (22 Oct. 2014) v1.0.0 - Initial commit (5 Apr. 2012)

Donate Bitcoins

Copyright (c) 2014 Francois-Guillaume Ribreau Licensed under the MIT license.