truncate
Truncate text and keep urls safe
Last updated 5 years ago by fgribreau .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install truncate 
SYNC missed versions from official npm registry.

Truncate

CircleCI Downloads available-for-advisory Twitter Follow Get help on Codementor Slack

Truncate text and keeps urls safe.

NPM

Install the module with: npm install truncate

Usage

// 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 :)"

Changelog

Donate

I maintain this project in my free time, if it helped you please support my work via paypal or bitcoins, thanks a lot!

License

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

Current Tags

  • 3.0.0                                ...           latest (5 years ago)

8 Versions

  • 3.0.0                                ...           5 years ago
  • 2.1.0                                ...           7 years ago
  • 2.0.1                                ...           8 years ago
  • 2.0.0                                ...           11 years ago
  • 1.0.5                                ...           11 years ago
  • 1.0.4                                ...           11 years ago
  • 1.0.2                                ...           13 years ago
  • 1.0.0                                ...           13 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |