Socket
Socket
Sign inDemoInstall

snappy

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snappy - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

.npmignore

2

package.json

@@ -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

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