Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lz4js

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lz4js

An Lz4 implementation for the browser.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Lz4.js NPM version Build Status codecov

Lz4.js is an implementation of Lz4 designed to be used in web browsers. It contains no dependencies on external libraries or Node.JS, though it is organized as a set of CommonJS modules. It is recommended to use Browserify or WebPack to bundle this for the web browser.

Installation

npm install lz4js

Usage

var lz4 = require("lz4js");
var fs = require("fs");

// Compress 128 bytes of zero.
var compressed = lz4.compress(new Array(128));

// Decompress.
var decompressed = lz4.decompress(compressed);

// Compress file.bin to file.lz4.
var data = fs.readFileSync("file.bin");
compressed = Buffer.from(lz4.compress(data));
fs.writeFileSync('file.lz4', compressed);

Note: The high-level compress and decompress functions deal with framed Lz4 data and do not support raw block data nor legacy Lz4 blocks.

API

The API accepts either Arrays or Uint8Arrays. Arrays are expected to be arrays of unsigned 8-bit values. The API will return Uint8Arrays if the browser supports them, or Arrays otherwise.

  • compress(buffer: Array, maxSize: Number): Array

    Compresses a buffer using Lz4. maxSize sets bounds on the output length; it is recommended to not specify this unless you know what you're doing. Any unused buffer data will be sliced before the buffer is returned.

  • decompress(buffer: Array, maxSize: Number): Array

    Decompresses a buffer using Lz4. maxSize sets bounds on the output length; if you know the output length, this will reduce memory usage somewhat. Any unused buffer data will be sliced before the buffer is returned.

Keywords

FAQs

Package last updated on 15 Jul 2016

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc