Socket
Book a DemoInstallSign in
Socket

lz4-wasm-nodejs

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lz4-wasm-nodejs

High Performance lz4 wasm implementation

0.9.2
latest
npmnpm
Version published
Weekly downloads
308
-9.94%
Maintainers
1
Weekly downloads
 
Created
Source

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

🚴 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

Release for bundler

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

Release for nodejs

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

Keywords

compression

FAQs

Package last updated on 27 Apr 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.