# lz4-wasm-nodejs

> High Performance lz4 wasm implementation

Latest version **0.9.2** (published 2022-04-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install lz4-wasm-nodejs
pnpm add lz4-wasm-nodejs
yarn add lz4-wasm-nodejs
bun add lz4-wasm-nodejs
```

## Health

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

Positive: has types; no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.2 |
| Published | 2022-04-27 |
| First published | 2021-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 41.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | pseitz |
| Keywords | compression, lz4, compress, decompression, decompress, wasm |

## Links

- npm: https://www.npmjs.com/package/lz4-wasm-nodejs
- npm.io page: https://npm.io/package/lz4-wasm-nodejs

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 0.9.2 (latest) — 2022-04-27
- 0.7.5 — 2021-04-22
- 0.7.4 — 2021-02-12
- 0.7.3 — 2021-02-12

## README

<div align="center">

  <h1><code>lz4-wasm</code></h1>

  <strong>Extremely fast compression(200MB/s Firefox, 350Mb/s Chrome) and decompression(600MB/s Firefox, 1400Mb/s Chrome) in the browser or nodejs using wasm.</strong>

  <sub>Built with Rust</a></sub>
</div>


## 🚴 Usage


The wasm module exposes two function compress and decompress.
Both accept and return UInt8Array. 
Internally the lz4 block api is used, the length of the original input is prepended in 32-bit little endian.


```

import * as wasm from "lz4-wasm";

// use TextEncoder to get bytes (UInt8Array) from string
var enc = new TextEncoder();
const compressed = wasm.compress(enc.encode("compress this text, compress this text pls. thx. thx. thx. thx. thx"));
const original = wasm.decompress(compressed);

var dec = new TextDecoder("utf-8");
alert(dec.decode(original))

```


See https://github.com/PSeitz/lz4_flex/tree/master/lz4-wasm/example_project for usage and benchmark.


## Making New Releases

### Release for bundler

Build. This will optimize usage for inside a bundler like webpack.
```
RUST_LOG=info wasm-pack build --release
```

Due to a long standing bug in wasm-pack 0.9.1, _manually_ add these files to pkg/package.json.

```
    "lz4_wasm_bg.wasm.d.ts",
```

```
RUST_LOG=info wasm-pack publish
```


### Release for nodejs

set name in Cargo toml to
```
name = "lz4-wasm-nodejs"
```

Build for nodejs
```
RUST_LOG=info wasm-pack build --release -t nodejs
```

```
RUST_LOG=info wasm-pack publish
```

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