truncate
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i truncate

Weekly Downloads

109,675

Version

3.0.0

License

MIT

Unpacked Size

11.4 kB

Total Files

8

Last publish

Collaborators

  • fgribreau