# lzf

> lzf compression module for nodejs

Latest version **0.3.0** (published 2014-10-24) · 0 weekly downloads

## Install

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

## 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.3.0 |
| Published | 2014-10-24 |
| First published | 2011-11-03 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 8 |
| Author | Ian Babrou |
| Maintainers | bobrik |
| Keywords | lzf, compression, buffer |

## Links

- npm: https://www.npmjs.com/package/lzf
- Repository: https://github.com/Topface/node-lzf
- Issues: https://github.com/Topface/node-lzf/issues
- npm.io page: https://npm.io/package/lzf

## Dependencies (1)

- [nan](https://npm.io/package/nan.md) 1.3.0

## 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

- 0.3.0 (latest) — 2014-10-24
- 0.2.0 — 2014-02-08
- 0.1.3 — 2013-07-02
- 0.1.2 — 2012-07-26
- 0.1.1 — 2011-12-20
- 0.1.0 — 2011-11-03

## README

## node-lzf

[LZF](http://oldhome.schmorp.de/marc/liblzf.html) compression library for nodejs.

LZF advantages:

* Small code size (less then 500 lines including header files and docs).
* Very fast compression speeds, rivaling a straight copy loop, especially for decompression which is basically at (unoptimized) memcpy-speed. Compression speed can be increased by 20% by sacrificing a few percent of compression ratio.
* Mediocre compression ratios - you can usually expect about 40-50% compression for typical binary data
* Easy to use (just two functions, no state attached)
* Highly portable (written in C)
* Tunable, see the file lzfP.h in the distribution, to tailor liblzf to your needs. The generated compressed blocks can be decompressed by any liblzf version regardless of the options used to compress.
* Freely usable (BSD-type-license)

### Usage

```javascript
var lzf = require("lzf");


var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." +
    "Curabitur volutpat, nulla nec egestas semper," +
    "ante dui tristique nibh, quis feugiat.";

// create buffer of your data
var loremBuffer = new Buffer(lorem);

// compress your buffer and get another buffer
var loremCompressed = lzf.compress(loremBuffer);

// decompress compressed buffer
var loremDecompressed = lzf.decompress(loremCompressed);

```

### Benchmarks

Benchmarks against [compress-buffer](https://github.com/egorFiNE/node-compress-buffer) library. Just to be short: it's faster.

```
Testing compression at 100 bytes
lzf-compress x 139,495 ops/sec ±11.88% (58 runs sampled)
zlib-compress x 29,879 ops/sec ±6.88% (88 runs sampled)
Fastest is lzf-compress

Testing decompression at 100 bytes
lzf-decompress x 36,574 ops/sec ±7.74% (87 runs sampled)
zlib-decompress x 26,153 ops/sec ±6.92% (89 runs sampled)
Fastest is lzf-decompress

Testing compression at 1000 bytes
lzf-compress x 57,345 ops/sec ±9.49% (81 runs sampled)
zlib-compress x 11,828 ops/sec ±3.93% (60 runs sampled)
Fastest is lzf-compress

Testing decompression at 1000 bytes
lzf-decompress x 29,221 ops/sec ±7.06% (89 runs sampled)
zlib-decompress x 19,351 ops/sec ±4.77% (92 runs sampled)
Fastest is lzf-decompress

Testing compression at 10000 bytes
lzf-compress x 10,512 ops/sec ±3.26% (92 runs sampled)
zlib-compress x 1,850 ops/sec ±0.20% (73 runs sampled)
Fastest is lzf-compress

Testing decompression at 10000 bytes
lzf-decompress x 12,487 ops/sec ±3.85% (91 runs sampled)
zlib-decompress x 6,939 ops/sec ±3.14% (93 runs sampled)
Fastest is lzf-decompress

Testing compression at 100000 bytes
lzf-compress x 1,628 ops/sec ±1.50% (96 runs sampled)
zlib-compress x 132 ops/sec ±0.13% (93 runs sampled)
Fastest is lzf-compress

Testing decompression at 100000 bytes
lzf-decompress x 2,472 ops/sec ±1.09% (91 runs sampled)
zlib-decompress x 1,430 ops/sec ±0.73% (95 runs sampled)
Fastest is lzf-decompress
```

---
### Authors
- Ian Babrou (ibobrik@gmail.com)

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