0.5.0 • Published 10 months ago
@chainsafe/snappy-wasm v0.5.0
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: Uint8Array = ...;
const compressed: Uint8Array = snappy.compress(data)
Decompress data
const decompressed: Uint8Array = snappy.decompress(compressed)
🛠️ 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
for communicating between WebAssembly and JavaScript.
👾 Development
Install the following