Comparing version 1.2.0 to 1.3.0
@@ -5,3 +5,3 @@ { | ||
"description": "Nodejs bindings to Google's Snappy compression library", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"homepage": "https://github.com/kesla/node-snappy", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -16,20 +16,46 @@ # Node-snappy [![Build Status](https://secure.travis-ci.org/kesla/node-snappy.png)](http://travis-ci.org/kesla/node-snappy) | ||
### String | ||
snappy = require('./snappy'); | ||
// Use synchronous version | ||
var compressed= snappy.compressSync('string to compress'); | ||
snappy.decompressSync(compressed, snappy.parsers.string); | ||
// result will be string instead of Buffer | ||
console.log(result); | ||
} | ||
```js | ||
var snappy = require('./snappy'); | ||
// Use synchronous version | ||
var compressed = snappy.compressSync('string to compress'); | ||
var result = snappy.decompressSync(compressed, snappy.parsers.string); | ||
// result will be string instead of Buffer | ||
console.log(result); | ||
``` | ||
### JSON | ||
snappy = require('./snappy'); | ||
// Snappy automatically convert json to a string | ||
snappy.compress({"foo": "bar"}, function(err, compressed){ | ||
snappy.decompress(compressed, snappy.parsers.json, function(err, result){ | ||
// result will be json instead of Buffer | ||
console.log(result["foo"]); | ||
} | ||
```js | ||
var snappy = require('./snappy'); | ||
// Snappy automatically convert json to a string | ||
snappy.compress({"foo": "bar"}, function(err, compressed){ | ||
snappy.decompress(compressed, snappy.parsers.json, function(err, result){ | ||
// result will be json instead of Buffer | ||
console.log(result["foo"]); | ||
} | ||
} | ||
``` | ||
## API | ||
### snappy.compress(input, cb) | ||
Compress `input`, which can be a Buffer, String or arbitrary JavaScript object and call `cb` with `err` and `compressed`. | ||
### snappy.compressSync(input) | ||
Compress `input`, which can be a Buffer, String or arbitrary JavaScript object and return `compressed`. Throws if an error occurs. | ||
### snappy.decompress(compressed, cb[, parse]) | ||
Decompress `compressed` using `parse` as parser (defaults to `raw`) and call `cb` with `err` and `decompressed`. | ||
### snappy.decompressSync(str, parse) | ||
Decompress `compressed` using `parse` as parser (defaults to `raw`) and return `decompressed`. Throws if an error occurs. | ||
## Parsers | ||
* json | ||
* string | ||
* raw | ||
# License | ||
@@ -36,0 +62,0 @@ Copyright (c) 2011 David Björklund |
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
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
5
565
80
1532610
54
1