Socket
Socket
Sign inDemoInstall

zlib-sync

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zlib-sync - npm Package Compare versions

Comparing version 0.0.1 to 0.1.2

binding.gyp

43

package.json
{
"name": "zlib-sync",
"description": "Synchronous compress/uncompress zlib/gzip/deflate formats wrapper over zlib for Node.js",
"homepage" : "http://ssuda.github.com/node-zlib-sync",
"bugs" : { "web" : "https://github.com/ssuda/node-zlib-sync/issues" },
"version": "0.0.1",
"author": "Sambasiva Suda",
"repository": {
"type": "git",
"url": "https://github.com/ssuda/node-zlib-sync"
},
"engine": [ "node >=0.4.0" ],
"main" : "./lib",
"scripts": {
"install": "./build.sh"
}
"name": "zlib-sync",
"version": "0.1.2",
"description": "Synchronous zlib bindings for NodeJS",
"main": "index.js",
"scripts": {
"lint": "eslint --fix test",
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git+https://github.com/abalabahaha/zlib-sync.git"
},
"keywords": [
"zlib",
"sync"
],
"author": "abalabahaha",
"license": "MIT",
"bugs": {
"url": "https://github.com/abalabahaha/zlib-sync/issues"
},
"homepage": "https://github.com/abalabahaha/zlib-sync#readme",
"dependencies": {
"nan": "^2.7.0"
},
"devDependencies": {
"mocha": "^4.0.1"
}
}

@@ -1,87 +0,57 @@

# node-zlib-sync
zlib-sync
=========
Synchronous compress/uncompress zlib/gzip/deflate formats wrapper over zlib for Node.js
Synchronous zlib for NodeJS
## Synopsis
Originally made for JS libraries interacting with the Discord gateway, where compression requires a shared zlib context in a synchronous fashion.
```javascript
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");
Features
--------
var compressed = compress(rawData);
var uncompressed = uncompress(compressed);
* Synchronous, [Pako](https://github.com/nodeca/pako)-like API
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);
* Near-native performance and efficiency
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);
Installing
----------
uncompressed == rawData // true!
`zlib-sync` is a native module, so it requires `node-gyp` to be installed, which requires Python 2.7 and a C++ compiler on your system. See [the node-gyp documentation](https://github.com/nodejs/node-gyp#installation) for more info. A pre-built module is planned for a future update.
After getting `node-gyp` set up, install `zlib-sync` like a normal NPM package:
```
npm install zlib-sync
```
## Options
compress/uncompress api returns Buffer() or throws an exception in case of an error
<pre>
rfc1950 is an alias for zlib
rfc1951 is an alias for deflate
rfc1952 is an alias for gzip
</pre>
Usage
-------
```javascript
Documentation can be found [here](https://github.com/abalabahaha/zlib-sync/wiki/Documentation).
zlib/gzip/deflatecompress(data, [options])
data - String or Buffer
options - options object
```js
var ZlibSync = require("zlib-sync");
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
var inflate = new ZlibSync.Inflate();
zlib/gzip/deflateuncompress(data, [windowbits])
8 <= windowBits => 15
```
inflate.push(compressedChunk1);
inflate.push(compressedChunk2, ZlibSync.Z_SYNC_FLUSH);
## Installation
if(inflate.err < 0) {
throw new Error("zlib error: " + inflate.msg);
}
npm install zlib-sync
var result = inflate.result;
or
console.log(result.toString());
```
npm install .
To-Do
-----
## License
* Deflate stream support
* One-time deflate/inflate support
See LICENSE file. Basically, it's a kind of "do-whatever-you-want-for-free" license.
License
-------
## Author
Sambasiva Suda <sambasivarao@gmail.com>
Refer to the [LICENSE](LICENSE) file.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc