node package manager

zlib-sync

node-zlib-sync

Synchronous compress/uncompress zlib/gzip/deflate formats wrapper over zlib for Node.js

Synopsis

    var zlib-sync = require('zlib-sync');
    
    //DEFLATE Format RFC-1951 
    var compress = zlib-sync.deflatecompress //zlib-sync.rfc1951compress; 
    var uncompress = zlib-sync.deflateuncompress //zlib-sync.rfc1951uncompress; 
    
    var rawData = fs.readFileSync("/etc/passwd");
 
    var compressed   = compress(rawData);
    var uncompressed = uncompress(compressed);
 
    uncompressed == rawData // true! 
    
    //ZLIB format RFC-1950 
    compress = zlib-sync.zlibcompress //zlib-sync.rfc1950compress; 
    uncompress = zlib-sync.zlibuncompress //zlib-sync.rfc1950uncompress; 
    
    compressed   = compress(rawData);
    uncompressed = uncompress(compressed);
 
    uncompressed == rawData // true! 
    
    //GZIP format RFC-1952 
    compress = zlib-sync.gzipcompress //zlib-sync.rfc1952compress; 
    uncompress = zlib-sync.gzipuncompress //zlib-sync.rfc1952uncompress; 
    
    compressed   = compress(rawData);
    uncompressed = uncompress(compressed);
 
    uncompressed == rawData // true! 
 

Options

compress/uncompress api returns Buffer() or throws an exception in case of an error

rfc1950 is an alias for zlib
rfc1951 is an alias for deflate
rfc1952 is an alias for gzip
 
zlib/gzip/deflatecompress(data, [options]) 
    data - String or Buffer
    options - options object
 
The options are
    1 <= options.compressionLevel <= 9
    8 <= options.windowBits  >= 15
    1 <= options.memlevel >= 9
    0 <= options.strategy => 4
        0 - Z_DEFAULT_STRATEGY,
        1 - Z_FILTERED
        2 - Z_HUFFMAN_ONLY
        3 - Z_RLE
        4 - Z_FIXED
    
 
zlib/gzip/deflateuncompress(data, [windowbits])
    8 <= windowBits => 15

Installation

npm install zlib-sync

or

npm install .

License

See LICENSE file. Basically, it's a kind of "do-whatever-you-want-for-free" license.

Author

Sambasiva Suda sambasivarao@gmail.com