npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lz4-napi

v2.8.0

Published

Fastest lz4 compression library in Node.js, powered by napi-rs and lz4-flex.

Downloads

49,370

Readme

lz4-napi

Node.js NAPI Binding for LZ4 compression algorithm, powered by Rust napi-rs and lz4-flex.

Pros:

  • Fast! ⚡️
  • Memory Safe! 🔒
  • Uses libuv's threadpool! 🧵

Table of content

Installation

npm i lz4-napi
# OR
yarn add lz4-napi

Usage

Compress

const { readFile } = require('fs/promises');
const { compress } = require('lz4-napi');

// if you support top-level await
const buffer = await readFile("./bigFile.dat");
const compressedBuffer = await compress(buffer)
// Store compressed buffer somewhere

Uncompress

const { uncompress } = require('lz4-napi');

// if you support top-level await
const compressedBuffer = await getFromSomeStorage();
const uncompressedBuffer = await uncompress(compressedBuffer)
// Do something with compressedBuffer!

APIs

Promise

compress

(data: Buffer | string | ArrayBuffer | Uint8Array, dict?: string | Buffer) => Promise<Buffer>

uncompress

(data: Buffer | string | ArrayBuffer | Uint8Array, dict?: string | Buffer) => Promise<Buffer>

Sync

compressSync

(data: Buffer | string | ArrayBuffer | Uint8Array, dict?: string | Buffer) => Buffer

uncompressSync

(data: Buffer | string | ArrayBuffer | Uint8Array, dict?: string | Buffer) => Buffer

Performance

Hardware

Benchmarks runs on the following hardware:

  • Processor Name: i9 9900K
  • Total Number of Cores: 8
  • Hyper-Threading Technology: Enabled
  • Memory: 32 GB

Benchmark

Running "Compress" suite...
Progress: 100%

  lz4:
    911 ops/s, ±18.64%     | 54.68% slower

  snappy:
    2 010 ops/s, ±19.23%   | fastest

  gzip:
    78 ops/s, ±18.76%      | 96.12% slower

  deflate:
    118 ops/s, ±20.42%     | 94.13% slower

  brotli:
    6 ops/s, ±0.21%       | slowest, 99.7% slower

Finished 5 cases!
  Fastest: snappy
  Slowest: brotli
Running "Decompress" suite...
Progress: 100%

  lz4:
    9 425 ops/s, ±12.50%   | fastest

  snappy:
    3 900 ops/s, ±13.39%   | 58.62% slower

  gzip:
    823 ops/s, ±20.48%     | slowest, 91.27% slower

  deflate:
    1 350 ops/s, ±12.52%   | 85.68% slower

  brotli:
    979 ops/s, ±11.55%     | 89.61% slower

Finished 5 cases!
  Fastest: lz4
  Slowest: gzip
Done in 61.20s.

Contributing

Project is pretty simple and straight forward for what is my needs, but if you have any idea you're welcome.

This projects uses conventional commit so be sure to use standard commit format or PR won't be accepted

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'feat(scope): some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Acknowledgments

License

Distributed under the MIT License. See LICENSE for more information.