# huffy

> A tiny compression library based on Huffman coding.

Latest version **1.2.1** (published 2025-01-26) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2025-01-26 |
| First published | 2022-12-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 16.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Maintainers | fabiospampinato |
| Keywords | tiny, huffman, coding, compression, decompression |

## Links

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

## Dependencies (1)

- [int32-encoding](https://npm.io/package/int32-encoding.md) ^1.0.1

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2025-01-26
- 1.2.0 — 2023-01-09
- 1.1.0 — 2023-01-09
- 1.0.0 — 2022-12-31

## README

# Huffy

A tiny compression library based on Huffman coding.

## Install

```sh
npm install huffy
```

## Usage

```ts
import {compress, decompress} from 'huffy';

// Let's make some data to compress

const str = 'some string to compress, it works better with longer things'.repeat ( 10 );
const buffer = new TextEncoder ().encode ( str );

// Let's compress and decompress it

const compressed = compress ( buffer );
const decompressed = decompress ( compressed );

// Let's print the compression ratio

console.log ( 'Compression ratio:', compressed.length / buffer.length );
```

## License

MIT © Fabio Spampinato

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