Comparing version 0.0.1 to 0.1.2
{ | ||
"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" | ||
} | ||
} |
102
README.md
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code which could be a vector to obscure malicious code, and generally decrease the likelihood of reproducible or reliable installs.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
624565
36
2
0
1
0
1
1
58
4
+ Addednan@^2.7.0
+ Addednan@2.20.0(transitive)