• This repository has been archived on 14/Sep/2023
  • Stars
    star
    481
  • Rank 91,384 (Top 2 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 13 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

DEPRECATED - please use https://github.com/Brooooooklyn/snappy. Nodejs bindings to Google's Snappy compression library

snappy Linux Status

FOSSA Status

Nodejs bindings to the snappy compression library

NPM

NPM

Installation

npm install snappy

Example

Input

var snappy = require('snappy')

snappy.compress('beep boop', function (err, compressed) {
  console.log('compressed is a Buffer', compressed)
  // return it as a string
  snappy.uncompress(compressed, { asBuffer: false }, function (err, original) {
    console.log('the original String', original)
  })
})

Output

compressed is a Buffer <SlowBuffer 09 20 62 65 65 70 20 62 6f 6f 70>
the original String beep boop

API

snappy.compress(input, callback)

Compress input, which can be a Buffer or a String.

The callback function will be called with a single error if the operation failed for any reason. If successful the first argument will be null and the second argument will be the value as a ``Buffer`.

snappy.compressSync(input)

The synchronous version of snappy.compress, returns the compressed value.

snappy.uncompress(compressed, [options,] callback)

Uncompress compressed and call callback with err and decompressed.

options

  • 'asBuffer' (boolean, default: true): Used to determine whether to return the value of the entry as a String or a Node.js Buffer object. Note that converting from a Buffer to a String incurs a cost so if you need a String (and the value can legitimately become a UFT8 string) then you should fetch it as one with asBuffer: true and you'll avoid this conversion cost.

The callback function will be called with a single error if the operation failed for any reason. If successful the first argument will be null and the second argument will be the value as a String or Buffer depending on the asBuffer option.

snappy.uncompressSync(compressed, [options])

The synchronous version of snappy.uncompress, returns the uncompressed value.

snappy.isValidCompressed(input, callback)

Check is input is a valid compressed Buffer.

The callback function will be called with a single error if the operation failed for any reason and the second argument will be true if input is a valid snappy compressed Buffer, false otherwise.

snappy.isValidCompressedSync(input)

The synchronous version of snappy.isValidCompressed, returns a boolean indicating if input was correctly compressed or not.

stream

For a streaming interface to snappy, please take a look at snappy-stream

Benchmark

This is the result I'm seeing on my laptop (Macbook Air from 2012) running node benchmark

  snappy.compress() x 479 ops/sec ยฑ0.99% (80 runs sampled)
  zlib.gzip() x 289 ops/sec ยฑ1.66% (86 runs sampled)
  snappy.uncompress() x 652 ops/sec ยฑ0.86% (43 runs sampled)
  zlib.gunzip() x 559 ops/sec ยฑ1.65% (64 runs sampled)

License

Copyright (c) 2011 - 2015 David Bjรถrklund & contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FOSSA Status

More Repositories

1

node-headless

Headless is a Node.js wrapper for Xvfb, the virtual framebuffer
JavaScript
91
star
2

sort-json

Takes a json-file and return a copy of the same file, but sorted
JavaScript
68
star
3

node-snappy-stream

Compress data over a Stream using the snappy framing format
JavaScript
52
star
4

node-leaky

Detect and report global leaking in source code strings.
JavaScript
44
star
5

parse-headers

JavaScript
26
star
6

css2json

Convert style sheets to json
HTML
25
star
7

download-npm-package

Download a module from the npm registry.
JavaScript
23
star
8

smart-crop

Get smart cropping coordinates to an images (based on https://github.com/thumbor/thumbor/wiki/Detection-algorithms)
JavaScript
20
star
9

async-replace

Run replace on a string and update it asynchronous
JavaScript
18
star
10

mysqlDOWN

An drop-in replacement for LevelDOWN that works in mysql
JavaScript
17
star
11

level-repair

Simple CLI to repair a leveldb-database
JavaScript
15
star
12

fast-future

A really fast way to run a callback in the future
JavaScript
14
star
13

rolling-checksum

node.js module to rolling calculate a checksum (adler-32)
JavaScript
12
star
14

dateselect

Dateselect - a time-based job scheduler with CSS-like selector syntax.
JavaScript
12
star
15

snappy.js

DEPRECATED: please use https://www.npmjs.com/package/snappyjs instead
JavaScript
10
star
16

jade-to-handlebars

JavaScript
9
star
17

compress-response

streaming http response compression thingy
JavaScript
7
star
18

download-tarball

Download a tarball (optionally gzipped) to a folder & extract it in the process
JavaScript
7
star
19

mit

node.js-module to create mit-licences
JavaScript
6
star
20

runtime-node-net

the net node.js-module for runtimejs
JavaScript
6
star
21

parallelify

An alternative api to run-parallel
JavaScript
6
star
22

node-synco

6
star
23

map-upsert

TypeScript
5
star
24

level-namespace

namespaces for levelup
JavaScript
5
star
25

get-package-json-from-github

Get a package.json from a npm module hosted on github
JavaScript
5
star
26

pidlockfile

Ensure that at most one instance is running, based on PIDs
JavaScript
5
star
27

get-npm-registry-package

JavaScript
5
star
28

mod_history

WIP history support for breach
JavaScript
4
star
29

tako-gzip

gzip compression for tako
JavaScript
4
star
30

download-package-tarball

Download a node package as a tarball, for example from github or npm
JavaScript
4
star
31

level-get-range

Get a range from levelup
JavaScript
4
star
32

resolve-npm-version

JavaScript
4
star
33

remove-unprintable

Small npm module to remove all unprintable characters from a string
JavaScript
3
star
34

run-parallel-object

Resolve functions in an object to values
JavaScript
3
star
35

kesla.github.io

My personal website
JavaScript
3
star
36

level-benchmarks

Run benchmarks on levelup-compatible modules.
JavaScript
3
star
37

get-package-json-from-registry

JavaScript
3
star
38

remotedown

A leveldown-compatible library to connect to a remote leveldown
JavaScript
3
star
39

offline-npm

JavaScript
3
star
40

level-cluster-get

Get a value from a cluster of multilevel instances
JavaScript
3
star
41

runtime-node-dns

JavaScript
3
star
42

async-benchmark

Thin wrapper around benchmark.js to run asyncronous benchmarks (because I always forget the API)
JavaScript
3
star
43

level-compare-forks

Run benchmarks on different level-forks and see how they compare
JavaScript
3
star
44

set-diffs

JavaScript
3
star
45

modify-package-dependencies

Modify package dependencies in a package.json object
JavaScript
3
star
46

leveldown-open

module to handle the logic of opening a leveldown instance
JavaScript
3
star
47

leap-year.rs

Rust
3
star
48

level-buffered-streams

Stream arrays from levelup
JavaScript
3
star
49

node-child-killer

Kill all the child processes as the master dies
JavaScript
3
star
50

svg-font

Parse a svg-font to a json object
JavaScript
3
star
51

append-stream

Write data to a file fast when you don't care about back-pressure
JavaScript
3
star
52

count-per-day

Get counts per day from a list of dates
JavaScript
3
star
53

sinopia-follow

JavaScript
2
star
54

fsreadcache

Cache calls to fs.read
JavaScript
2
star
55

thumbor-to-sharp-image

Create sharp image from thumbor object
JavaScript
2
star
56

level-cbatch

A chainable api for batch() in levelup
JavaScript
2
star
57

bubbel

If you just love javascripts prototype-function and wanna do the same for ruby, this is for you.
Ruby
2
star
58

node-s3upload

An opinionated application to upload a folder to a s3 bucket.
JavaScript
2
star
59

jsonmark

Parse markdown to a very simple json-format that can then be stringified back to markdown
JavaScript
2
star
60

http-test-server

Create a simple http server, suitable for tests
JavaScript
2
star
61

pubhub

A simple PubSubHubbub server written in node.js
JavaScript
2
star
62

run-object-basis

Base repo for run-series-object & run-parallel-object
JavaScript
2
star
63

dyi

TypeScript
2
star
64

design-challenges

JavaScript
2
star
65

run-series-object

Resolve functions in an object to values
JavaScript
2
star
66

keydir

A sorted list of keys with support for level-* ranges
JavaScript
2
star
67

forward-leveldown

An abstract-leveldown variant where all missing methods get redirected to another leveldown-instance
JavaScript
2
star
68

async-cache-promise

JavaScript
2
star
69

create-objects

node library to efficiently and simple create javascript objects from arrays
JavaScript
2
star
70

unlink-empty-files

given a directory, unlink (remove) all files with a length of 0
JavaScript
2
star
71

level-cluster-consistency

Given a key, figure out if a cluster of level-instances are consistent
JavaScript
2
star
72

github-licence

node.js-module to get the licence of a github-project
JavaScript
2
star
73

fast-cache

Caches a method that returns a promise and does so really fast.
JavaScript
1
star
74

then-tmp

Promised version of the `tmp` module
JavaScript
1
star
75

normalize-npm-registry-package

JavaScript
1
star
76

reservoir-stream

A streaming interface to do reservoir sampling
JavaScript
1
star
77

cron

adds and removes jobs that emit Hook events on customizable time intervals
JavaScript
1
star
78

simple-reconnect-ws

Simple reconnct logic for websockets (to use with browserify)
JavaScript
1
star
79

download-github-package

Download a node module from github.
JavaScript
1
star
80

versions-from-filenames

JavaScript
1
star
81

buffered-transform

Buffer up data and give it to a transform-like method
JavaScript
1
star
82

node-invert-object

Invert a javascript-object
JavaScript
1
star
83

html-minifyify

browserify transform to inline calls to html-minifier
JavaScript
1
star
84

autobahn

JavaScript
1
star
85

identify-licence

node module to identify licences from strings
JavaScript
1
star
86

unique-ids

Transform html so that all ids are unique
JavaScript
1
star
87

riak-browser

html/javascript/jquery/jquery-ui riak bucket browser/navigator
Shell
1
star
88

node-gendr

Library for deciding gender out of a name. Uses wikipedia as source, and redis as cache.
CoffeeScript
1
star
89

levelup-util

the lib/util.js-file from levelup in it's own module
JavaScript
1
star
90

weighted-median-rs

Rust
1
star
91

level-set2

Treat a value in level like a Set
JavaScript
1
star
92

trailing-slashes

Trailing slash redirect thingy
JavaScript
1
star
93

get-ideal-package-tree

Given a list of npm packages. returns the ideal tree - the best tree to fulfil all dependencies (using a similar approach to npm v3)
JavaScript
1
star
94

run-alternative

base package for seriesify & parallelify
JavaScript
1
star
95

html-nav

Create a navigation based on header-elements (e.g h1)
JavaScript
1
star
96

leftover

Call callbacks a couple of times and return with the last data
JavaScript
1
star
97

run-concurrent

Run an array of functions concurrently, with a maximum of active tasks
JavaScript
1
star
98

readout

A simple node.js module and executable to automagically create and update a Readme.md file
JavaScript
1
star
99

level-auto-batch

collect all puts and dels in the same tick in one batch
JavaScript
1
star
100

micropause

A collaborative take on micro pauses
1
star