🗜️⚡WebAssembly power compression and decompression in the browser and server. Supports GZIP, ZLIB and DEFLATE
wasm-flate
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.
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.
Pass a base64 string of the compressed data and it will return a base64 decompressed value.
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
cargo build --target wasm32-wasi --release --features "strings"
wasmer run target/wasm32-wasi/debug/basic.wasm
wapm install drbh/flate
wapm run flate_basic "hello world"
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…).
wasm-pack build -- --features "browser strings"
wasm-pack build --target nodejs -- --features "browser strings"
wasm-pack build --target no-modules -- --features "browser strings"
wasm-pack build --target bundler -- --features "browser strings"
If you found wasm-flate
useful feel free to buy me a beer 🍺 or two 😀
BTC - 3QVK6D5QCZDSyLzFL3ZbELokyuSprRQQZF