Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

snappy

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snappy

Fastest Snappy compression library in Node.js

  • 7.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
336K
decreased by-9.57%
Maintainers
2
Weekly downloads
 
Created

What is snappy?

The 'snappy' npm package is a Node.js binding for Google's Snappy compression library. It provides fast and efficient compression and decompression functionalities, making it suitable for applications that require high-speed data processing.

What are snappy's main functionalities?

Compression

This feature allows you to compress a given input buffer using Snappy's compression algorithm. The code sample demonstrates how to compress a simple 'Hello, world!' string.

const snappy = require('snappy');
const input = Buffer.from('Hello, world!');
snappy.compress(input, (err, compressed) => {
  if (err) throw err;
  console.log('Compressed:', compressed);
});

Decompression

This feature allows you to decompress a previously compressed buffer. The code sample shows how to uncompress data and convert it back to its original form.

const snappy = require('snappy');
const compressed = Buffer.from('compressed data here');
snappy.uncompress(compressed, { asBuffer: true }, (err, original) => {
  if (err) throw err;
  console.log('Decompressed:', original.toString());
});

Stream Compression

This feature provides stream-based compression, which is useful for handling large files or data streams. The code sample demonstrates how to compress a file using streams.

const snappy = require('snappy');
const fs = require('fs');
const input = fs.createReadStream('input.txt');
const output = fs.createWriteStream('output.snappy');
input.pipe(snappy.compressStream()).pipe(output);

Stream Decompression

This feature provides stream-based decompression. The code sample shows how to decompress a file using streams.

const snappy = require('snappy');
const fs = require('fs');
const input = fs.createReadStream('output.snappy');
const output = fs.createWriteStream('decompressed.txt');
input.pipe(snappy.uncompressStream()).pipe(output);

Other packages similar to snappy

Keywords

FAQs

Package last updated on 13 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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