# node-truncate

> String truncate for Node.js

Latest version **0.1.0** (published 2016-12-23) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-12-23 |
| First published | 2016-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Alex Svetkin |
| Maintainers | alex_svetkin |

## Links

- npm: https://www.npmjs.com/package/node-truncate
- Repository: https://github.com/whisk/node-truncate
- Homepage: https://github.com/whisk/node-truncate#readme
- Issues: https://github.com/whisk/node-truncate/issues
- npm.io page: https://npm.io/package/node-truncate

## Recent versions

- 0.1.0 (latest) — 2016-12-23
- 0.0.2 — 2016-04-11
- 0.0.1 — 2016-04-11

## README

# node-truncate

[![Build Status](https://travis-ci.org/whisk/node-truncate.svg?branch=master)](https://travis-ci.org/whisk/node-truncate)

## Synopsis

Truncate strings and buffers nicely for Node.js. Extends String and Buffer prototypes.

## Code Example

```
> 'This long string to be truncated to length 16'.truncate(16);
'This long str...'

> 'Now with different ending'.truncate(16, '--');
'Now with diffe--'

> 'Default length is 80, so this is not truncated'.truncate();
'Default length is 80, so this is not truncated'

> new Buffer('c297a382dc5de998016d', 'hex').truncate(12) // converts to hex string
'c297a382d...'

> new Buffer('c297a382dc5de998016d', 'hex').truncate(12, 'base64') // converts to base64 string
'wpejgtxd6...'
```

Default truncation length is 80, but you can override it globally:
```
require('truncate')(100);
```

## License

MIT

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