# snappy-wasm

> snappy compression/decompression for browsers and Node.js, powered by WebAssembly

Latest version **0.3.0** (published 2022-10-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install snappy-wasm
pnpm add snappy-wasm
yarn add snappy-wasm
bun add snappy-wasm
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2022-10-13 |
| First published | 2022-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 85.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nick Frasser |
| Maintainers | nfrasser |
| Keywords | snappy, browser, node, webassembly, wasm, compression |

## Links

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

## 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.3.0 (latest) — 2022-10-13
- 0.2.0 — 2022-04-11
- 0.1.0 — 2022-04-11

## README

<div align="center">

  <h1><code>snappy-wasm</code></h1>

  <strong>JavaScript compression/decompression with [snappy](https://github.com/google/snappy) for browsers and Node.js, powered by WebAssembly.</strong>

  <a href="https://www.npmjs.com/package/snappy-wasm"><img src="https://badgen.net/npm/v/snappy-wasm"></a>

  <sub>Built with 🦀🕸 by <a href="https://rustwasm.github.io/">The Rust and WebAssembly Working Group</a></sub>

</div>

## Installation

```
npm i snappy-wasm
```

## 🚴 Usage

### Browser / ES Modules


```js
import init from 'snappy-wasm'

// ...
const snappy = await init()
```

Note that additional configuration may be required to support top-level await in your environment.

### Node.js

```js
const snappy = require('snappy-wasm')
```

For use exclusively in Node.js, the [`snappy`](https://www.npmjs.com/package/snappy) package may provide better performance.

### Compress data

```js
const data = "data"
const compressed = snappy.compress(data)
```

This returns a `Uint8Array` instance

### Decompress data

```js
const decompressed = snappy.decompress(compressed)
```

Use `snappy.compress_raw(data)` and `snappy.decompress_raw(compressed)` to
compress/decompress raw data (provided and returned as `Uint8Array`)

### 🛠️ Build with `wasm-pack build` (via npm script)

```
npm run build
```

### 🔬 Test in Headless Browsers with `wasm-pack test`

```
wasm-pack test --headless --firefox
```

### 🎁 Publish to NPM

```
npm run build
npm publish
```

## 🔋 Batteries Included

* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating
  between WebAssembly and JavaScript.
* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook)
  for logging panic messages to the developer console.

## 👾 Development

Install the following

* [Node.js 16+](https://nodejs.org/en/)
* [Rust 2018](https://www.rust-lang.org/tools/install)
* [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/)

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