Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Node.js bindings for Snappy

tag: v1.4

Fetching latest commit…

Cannot retrieve the latest commit at this time

Readme.md

This is a fork of kesla's node-snappy. Simple async binding and no more :)

node-snappy Build Status

Node.js bindings for Google's fast compressor/decompressor: http://code.google.com/p/snappy/

Install

npm install snappy

Simple Benchmark

Testfile:
  https://raw.github.com/Skomski/node-snappy/master/test/urls.10K
  size: 702087 bytes

Compression:
  snappy: 357267 bytes
  zlib(level:1): 253263 bytes

Speed:
  zlib x 68.30 ops/sec ±1.52% (56 runs sampled)
  snappy x 361 ops/sec ±0.94% (61 runs sampled)

Usage

var Snappy = require('snappy');
var buffer = new Buffer([255, 200, 100, 3, 0, 256, 80]);

Snappy.compress(buffer, function(err, compressed){
  if (err) throw err;

  Snappy.decompress(compressed, function(err, decompressed){
    if (err) throw err;
  });
});

Methods

compress(buffer, cb)

  • Required:
    • buffer - Raw buffer
    • cb - Function with two arguments (err, compressedBuffer)

decompress(buffer, cb)

  • Required:
    • buffer - Compressed buffer
    • cb - Function with two arguments (err, decompressedBuffer)

License

Licensed under the MIT license.

Something went wrong with that request. Please try again.