# tiny-truncate

> A tiny function for truncating a string which may containg ANSI escapes, with automatic terminal width detection.

Latest version **1.0.5** (published 2025-08-22) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 50/100 (C)** — status: stable.

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

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2025-08-22 |
| First published | 2022-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 2.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | fabiospampinato |
| Keywords | tiny, truncate |

## Links

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

## Dependencies (1)

- [ansi-truncate](https://npm.io/package/ansi-truncate.md) ^1.4.0

## 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.5 (latest) — 2025-08-22
- 1.0.4 — 2025-08-04
- 1.0.3 — 2025-01-12
- 1.0.2 — 2022-05-06
- 1.0.1 — 2022-05-06
- 1.0.0 — 2022-05-06

## README

# Tiny Truncate

A tiny function for truncating a string which may containg ANSI escapes, with automatic terminal width detection.

## Install

```sh
npm install tiny-truncate
```

## Usage

```ts
import colors from 'tiny-colors';
import truncate from 'tiny-truncate';

// Let's truncate a string, spanning at most the entire width of the terminal

truncate ( colors.red ( '---'.repeat ( 1000 ) ) ); // Some red dashes that don't overflow the width of the terminal
```

## License

MIT © Fabio Spampinato

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