# ljd-clamp

> Simple text clamping

Latest version **0.1.1** (published 2015-08-16) · WTFPL - http://www.wtfpl.net/ license · 0 weekly downloads

## Install

```sh
npm install ljd-clamp
pnpm add ljd-clamp
yarn add ljd-clamp
bun add ljd-clamp
```

## 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.1 |
| Published | 2015-08-16 |
| First published | 2015-06-04 |
| Weekly downloads | 0 |
| License | WTFPL - http://www.wtfpl.net/ |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Laust Deleuran |
| Maintainers | laustdeleuran |
| Keywords | text, clamp, js |

## Links

- npm: https://www.npmjs.com/package/ljd-clamp
- Repository: https://github.com/laustdeleuran/clamp
- Homepage: https://github.com/laustdeleuran/clamp#readme
- Issues: https://github.com/laustdeleuran/clamp/issues
- npm.io page: https://npm.io/package/ljd-clamp

## Dependencies (2)

- [extend](https://npm.io/package/extend.md) ^2.0.1
- [computed-style](https://npm.io/package/computed-style.md) ^0.3.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.1 (latest) — 2015-08-16
- 0.1.0 — 2015-06-04

## README

# Clamp

Text clamping JS-style. Largely inspired by [Joseph Schmitt's $clamp](https://github.com/josephschmitt/Clamp.js), but largely simplified to avoid the issues that library has. 



## Usage

Initialize a `Clamp` instance on an element containing a single text node:

	new Clamp(HTMLElement, optionsObject);



## Methods

### `.render()`

Renders clamp based on current layout. Can be used to relayout if layout changes, such as on `resize`.

### `.reset()`

Resets text node to contain original content



## Options

### `lines` {Integer} (Default: `2`)

Probably the most important option. Specify how many lines you want. 

### `splitOnChars` {Array} (Default: `['.', '-', '–', '—', ' ']`)

Defines characters to split in prioritized order. Defaults to sentences (periods), hypens, en-dashes, em-dashes, and words (spaces).

### `truncationChar` {String} (Default: `'…'`)

Character to append to truncated string. Defaults to a simple ellipsis.



## Contact, attribution & contribution

All code here is either created by me or shamelessly stolen from other great libraries. I've tried to attribute authors whenever relevant. Contribute by simply forking your own repository and commit away. 

I will review pull requests as quickly as I can.

If anything leaves a bad taste in your mouth, contact info can be found at [ljd.dk](http://ljd.dk).



## License

_Clamp_ is licensed under [WTFPL](http://www.wtfpl.net/).

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