
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
lz4-wasm-nodejs
Advanced tools
lz4-wasm
Extremely fast compression(200MB/s Firefox, 350Mb/s Chrome) and decompression(600MB/s Firefox, 1400Mb/s Chrome) in the browser or nodejs using wasm.
Built with Rust
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.
Build. This will optimize usage for inside a bundler like webpack.
RUST_LOG=info wasm-pack build --release
Due to a long standing bug in wasm-pack 0.9.1, manually add these files to pkg/package.json.
"lz4_wasm_bg.wasm.d.ts",
RUST_LOG=info wasm-pack publish
set name in Cargo toml to
name = "lz4-wasm-nodejs"
Build for nodejs
RUST_LOG=info wasm-pack build --release -t nodejs
RUST_LOG=info wasm-pack publish
FAQs
High Performance lz4 wasm implementation
The npm package lz4-wasm-nodejs receives a total of 242 weekly downloads. As such, lz4-wasm-nodejs popularity was classified as not popular.
We found that lz4-wasm-nodejs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.