wasm-flate

🗜️⚡WebAssembly power compression and decompression in the browser and server. Supports GZIP, ZLIB and DEFLATE


Project maintained by drbh

wasm-flate

npm version dependencies Status

Why use wasm-flate

image

WASM npm library for fast (de)compression

Uses

This package allows you to quickly compress and decompress data in the browser. The process is simple and optmized to execute as fast as your browser can run.

Compress

Pass a string or Uint8Array to the compression function you choose. The contents will be compressed and encoded to base64. The returned value will be a base64 encoded string.

Decompress

Pass a base64 string of the compressed data and it will return a base64 decompressed value.

Topics

Server side

We want to build with WASI so we can run wasm-flate on a server. All we need to do is pass the target that we want and now we can execute the wasm binary with a server side VM like wasmer

Build for wasi

cargo build --target wasm32-wasi --release --features "strings"
wasmer run target/wasm32-wasi/debug/basic.wasm 

WAPM

wapm install drbh/flate
wapm run flate_basic "hello world"

Client side

We want to build with wasm bindgen because it will automatically generate the needed JS files that communicate with the wasm binary.

This Javascript file can be generated for a varity of targets. We can build with no modules for static pages and also build for times we need a bundlers (webpack, parcel…).

Build for ES6

wasm-pack build -- --features "browser strings"

Build for NodeJS

wasm-pack build --target nodejs -- --features "browser strings"

Build for browser

wasm-pack build --target no-modules -- --features "browser strings"

Build for bundler

wasm-pack build --target bundler -- --features "browser strings"

Topics

If you found wasm-flate useful feel free to buy me a beer 🍺 or two 😀
BTC - 3QVK6D5QCZDSyLzFL3ZbELokyuSprRQQZF