npm.io
0.3.0 • Published 4 years ago

snappy-wasm

Licence
MIT
Version
0.3.0
Deps
0
Size
85 kB
Vulns
0
Weekly
0

snappy-wasm

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

Built with by The Rust and WebAssembly Working Group

Installation

npm i snappy-wasm

Usage

Browser / ES Modules
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
const snappy = require('snappy-wasm')

For use exclusively in Node.js, the snappy package may provide better performance.

Compress data
const data = "data"
const compressed = snappy.compress(data)

This returns a Uint8Array instance

Decompress data
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

Development

Install the following

Keywords