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

@broadly/lzf

v0.3.2

Published

lzf compression module for nodejs

Downloads

7

Readme

node-lzf

LZF compression library for nodejs.

LZF advantages:

  • Small code size (less then 500 lines including header files and docs).
  • Very fast compression speeds, rivaling a straight copy loop, especially for decompression which is basically at (unoptimized) memcpy-speed. Compression speed can be increased by 20% by sacrificing a few percent of compression ratio.
  • Mediocre compression ratios - you can usually expect about 40-50% compression for typical binary data
  • Easy to use (just two functions, no state attached)
  • Highly portable (written in C)
  • Tunable, see the file lzfP.h in the distribution, to tailor liblzf to your needs. The generated compressed blocks can be decompressed by any liblzf version regardless of the options used to compress.
  • Freely usable (BSD-type-license)

Usage

var lzf = require("lzf");


var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." +
    "Curabitur volutpat, nulla nec egestas semper," +
    "ante dui tristique nibh, quis feugiat.";

// create buffer of your data
var loremBuffer = new Buffer(lorem);

// compress your buffer and get another buffer
var loremCompressed = lzf.compress(loremBuffer);

// decompress compressed buffer
var loremDecompressed = lzf.decompress(loremCompressed);

Benchmarks

Benchmarks against compress-buffer library. Just to be short: it's faster.

Testing compression at 100 bytes
lzf-compress x 139,495 ops/sec ±11.88% (58 runs sampled)
zlib-compress x 29,879 ops/sec ±6.88% (88 runs sampled)
Fastest is lzf-compress

Testing decompression at 100 bytes
lzf-decompress x 36,574 ops/sec ±7.74% (87 runs sampled)
zlib-decompress x 26,153 ops/sec ±6.92% (89 runs sampled)
Fastest is lzf-decompress

Testing compression at 1000 bytes
lzf-compress x 57,345 ops/sec ±9.49% (81 runs sampled)
zlib-compress x 11,828 ops/sec ±3.93% (60 runs sampled)
Fastest is lzf-compress

Testing decompression at 1000 bytes
lzf-decompress x 29,221 ops/sec ±7.06% (89 runs sampled)
zlib-decompress x 19,351 ops/sec ±4.77% (92 runs sampled)
Fastest is lzf-decompress

Testing compression at 10000 bytes
lzf-compress x 10,512 ops/sec ±3.26% (92 runs sampled)
zlib-compress x 1,850 ops/sec ±0.20% (73 runs sampled)
Fastest is lzf-compress

Testing decompression at 10000 bytes
lzf-decompress x 12,487 ops/sec ±3.85% (91 runs sampled)
zlib-decompress x 6,939 ops/sec ±3.14% (93 runs sampled)
Fastest is lzf-decompress

Testing compression at 100000 bytes
lzf-compress x 1,628 ops/sec ±1.50% (96 runs sampled)
zlib-compress x 132 ops/sec ±0.13% (93 runs sampled)
Fastest is lzf-compress

Testing decompression at 100000 bytes
lzf-decompress x 2,472 ops/sec ±1.09% (91 runs sampled)
zlib-decompress x 1,430 ops/sec ±0.73% (95 runs sampled)
Fastest is lzf-decompress

Authors