Package Exports
- lz4-wasm-nodejs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lz4-wasm-nodejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
lz4-wasm
Extremely fast compression(200MB/s) and decompression(600MB/s) in the browser or nodejs using wasm.
Built with Rust
🚴 Usage
The wasm module exposes two function compress and decompress. Both accept and return UInt8Array. Internally the lz4 block api is used, the length of the original input is prepended in 32-bit little endian.
import * as wasm from "lz4-wasm";
// use TextEncoder to get bytes (UInt8Array) from string
var enc = new TextEncoder();
const compressed = wasm.compress(enc.encode("compress this text, compress this text pls. thx. thx. thx. thx. thx"));
const original = wasm.decompress(compressed);
var dec = new TextDecoder("utf-8");
alert(dec.decode(original))
See https://github.com/PSeitz/lz4_flex/tree/master/lz4-wasm/example_project for usage and benchmark.
Making New Releases
Build. This will optimize usage for inside a bundler like webpack.
RUST_LOG=info wasm-pack build --releaseDue to a long standing bug in wasm-pack 0.9.1, manually add these files to package.json.
"lz4_wasm_bg.wasm.d.ts",
"lz4_wasm_bg.js",RUST_LOG=info wasm-pack publishRelease for nodejs
set name in Cargo toml to
name = "lz4-wasm-nodejs"Build for nodejs
RUST_LOG=info wasm-pack build --release -t nodejsDue to a long standing bug in wasm-pack 0.9.1, manually add these files to package.json.
"lz4_wasm_bg.wasm.d.ts",
"lz4_wasm_bg.js",RUST_LOG=info wasm-pack publish