# lz4js

> An Lz4 implementation for the browser.

Latest version **0.2.0** (published 2016-07-15) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2016-07-15 |
| First published | 2016-07-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/lz4js) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 102 |
| Author | John Chadwick |
| Maintainers | johnwchadwick |
| Keywords | lz4, compression, decompression, browser, commonjs |

## Links

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

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2016-07-15
- 0.1.3 — 2016-07-07
- 0.1.2 — 2016-07-07
- 0.1.1 — 2016-07-05
- 0.1.0 — 2016-07-05

## README

# Lz4.js [![NPM version](https://badge.fury.io/js/lz4js.svg)](https://www.npmjs.com/package/lz4js) [![Build Status](https://travis-ci.org/Benzinga/lz4js.svg?branch=master)](https://travis-ci.org/Benzinga/lz4js) [![codecov](https://codecov.io/gh/Benzinga/lz4js/branch/master/graph/badge.svg)](https://codecov.io/gh/Benzinga/lz4js)
Lz4.js is an implementation of Lz4 designed to be used in web browsers. It contains no dependencies on external libraries or Node.JS, though it is organized as a set of CommonJS modules. It is recommended to use Browserify or WebPack to bundle this for the web browser.

## Installation
```
npm install lz4js
```

## Usage
```javascript
var lz4 = require("lz4js");
var fs = require("fs");

// Compress 128 bytes of zero.
var compressed = lz4.compress(new Array(128));

// Decompress.
var decompressed = lz4.decompress(compressed);

// Compress file.bin to file.lz4.
var data = fs.readFileSync("file.bin");
compressed = Buffer.from(lz4.compress(data));
fs.writeFileSync('file.lz4', compressed);
```

> **Note**: The high-level `compress` and `decompress` functions deal with framed Lz4 data and do not support raw block data nor legacy Lz4 blocks.

## API
The API accepts either `Array`s or `Uint8Array`s. Arrays are expected to be arrays of unsigned 8-bit values. The API will return `Uint8Array`s if the browser supports them, or `Array`s otherwise.

  - `compress(buffer: Array, maxSize: Number): Array`

    Compresses a buffer using Lz4. maxSize sets bounds on the output length; it is recommended to not specify this unless you know what you're doing.
    Any unused buffer data will be sliced before the buffer is returned.

  - `decompress(buffer: Array, maxSize: Number): Array`

    Decompresses a buffer using Lz4. maxSize sets bounds on the output length; if you know the output length, this will reduce memory usage somewhat.
    Any unused buffer data will be sliced before the buffer is returned.

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