# limit-characters

> Limit characters with different criteria

Latest version **1.0.3** (published 2021-01-19) · 0 weekly downloads

## Install

```sh
npm install limit-characters
pnpm add limit-characters
yarn add limit-characters
bun add limit-characters
```

## 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 | 1.0.3 |
| Published | 2021-01-19 |
| First published | 2020-05-30 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Elisha Terada |
| Maintainers | elishaterada |
| Keywords | truncate, characters, limit, break-word |

## Links

- npm: https://www.npmjs.com/package/limit-characters
- Repository: https://github.com/elishaterada/limit-characters
- Homepage: https://github.com/elishaterada/limit-characters#readme
- Issues: https://github.com/elishaterada/limit-characters/issues
- npm.io page: https://npm.io/package/limit-characters

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-01-19
- 1.0.2 — 2020-11-23
- 1.0.1 — 2020-05-30
- 1.0.0 — 2020-05-30

## README

# limit-characters

Limits the length of a given text with different options. Types included.

## Install

**npm**

```shell
npm i limit-characters
```

**Yarn**

```shell
yarn add limit-characters
```

## Usage

**CommonJS**

```javascript
var limitCharacters = require("limit-characters")
```

**ES6**

```javascript
import limitCharacters from "limit-characters"
```

## Example

```javascript
import limitCharacters from "limit-characters";

const originalText = "This library helps limit the characters of a given text"

const excerpt = limitCharacters({ text: originalText, length: 20 })
// Returns "This library help..."

const excerpt2 = limitCharacters({ text: originalText, length: 20, breakWord: false })
// Returns "This library..."

const excerpt3 = limitCharacters({ text: originalText, length: 32, breakWord: false, more: "... read more" })
// Returns "This library helps... read more"
```

## Options

| Option    | Type    | Required | Default | Description                                                        |
|-----------|---------|----------|---------|--------------------------------------------------------------------|
| text      | string  | Required |         | Original text to trim                                              |
| length    | number  | Optional | `144`   | Max length of characters including ellipsis                        |
| breakWord | boolean | Optional | `true`  | Break the word or keep the whole word that fits the length         |
| more      | string  | Optional | `...`   | Appended at the end of string if original text exceeded the length |

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