Giter Club home page Giter Club logo

node-lzf's Introduction

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

node-lzf's People

Contributors

bobrik avatar codeaholics avatar djanowski avatar ericwaldheim avatar fadimko avatar jmealo avatar pconstr avatar stevede avatar trkyshorty avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.