# truncate

> Truncate text and keep urls safe

Latest version **3.0.0** (published 2021-09-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install truncate
pnpm add truncate
yarn add truncate
bun add truncate
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2021-09-28 |
| First published | 2013-04-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52 |
| Author | Francois-Guillaume Ribreau |
| Maintainers | fgribreau |

## Links

- npm: https://www.npmjs.com/package/truncate
- Repository: https://github.com/FGRibreau/node-truncate
- Issues: https://github.com/FGRibreau/node-truncate/issues
- npm.io page: https://npm.io/package/truncate

## Recent versions

- 3.0.0 (latest) — 2021-09-28
- 2.1.0 — 2019-05-29
- 2.0.1 — 2018-02-24
- 2.0.0 — 2015-09-17
- 1.0.5 — 2015-07-26
- 1.0.4 — 2014-10-22
- 1.0.2 — 2013-04-05
- 1.0.0 — 2013-04-05

## README

Truncate
==================

[![CircleCI](https://img.shields.io/circleci/project/github/FGRibreau/node-truncate.svg)]() [![Downloads](http://img.shields.io/npm/dm/truncate.svg)](https://www.npmjs.com/package/truncate) [![available-for-advisory](https://img.shields.io/badge/available%20for%20consulting%20advisory-yes-ff69b4.svg?)](http://bit.ly/2c7uFJq) [![Twitter Follow](https://img.shields.io/twitter/follow/fgribreau.svg?style=flat)](https://twitter.com/FGRibreau) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/francois-guillaume-ribreau?utm_source=github&utm_medium=button&utm_term=francois-guillaume-ribreau&utm_campaign=github) [![Slack](https://img.shields.io/badge/Slack-Join%20our%20tech%20community-17202A?logo=slack)](https://join.slack.com/t/fgribreau/shared_invite/zt-edpjwt2t-Zh39mDUMNQ0QOr9qOj~jrg)

Truncate text and keeps urls safe.

## NPM
Install the module with: `npm install truncate`

## Usage

```javascript
// Browser
String.truncate("1234 http://google.com hey :)", 2) === "12…"
```

```javascript
// 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](/CHANGELOG.md)

## Donate

I maintain this project in my free time, if it helped you please support my work via [paypal](https://paypal.me/fgribreau) or [bitcoins](https://www.coinbase.com/fgribreau), thanks a lot!

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

---
_Source: https://npm.io/package/truncate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
