snappy-wasm
v0.3.0
Published
snappy compression/decompression for browsers and Node.js, powered by WebAssembly
Downloads
77
Maintainers
Readme
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
wasm-bindgen
for communicating between WebAssembly and JavaScript.console_error_panic_hook
for logging panic messages to the developer console.
👾 Development
Install the following