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

compress-buffer

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compress-buffer

Single-step Buffer compression library for Node.js

  • 0.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
117
decreased by-55.68%
Maintainers
1
Weekly downloads
 
Created
Source

node-compress-buffer

A single-step Buffer compression library for Node.js.

Synopsis

	compress = require('compress-buffer').compress;
	uncompress = require('compress-buffer').uncompress;
	
	var rawData = fs.readFileSync("/etc/passwd");

	var compressed   = compress(rawData);
	var uncompressed = uncompress(compressed);

	uncompressed == rawData // true!

Why?

For the sake of the KISS principle. Most of the time you don't need a streaming compression, you need to compress an existing and already complete data.

Options

compress() takes two arguments: the data (must be a Buffer()) and optional compression level which must be within 1..9. It returns compressed Buffer() or undefined on error.

uncompress() takes a single argument: the data (must be a Buffer()) and returns uncompressed Buffer() or undefined on error.

Installation

npm install compress-buffer

or

npm install .

Upgrade notice

In version 0.4.1 I removed support for strings compression. It is not possible to correctly determine the encoding of an input string and different encoding yields different results. So for the sake of consistency and reliability this was removed.

Use the following instead:

	var compressedBuffer = compress(new Buffer("my string"));

License

See LICENSE file. Basically, it's a kind of "do-whatever-you-want-for-free" license.

Thanks to

  • A lot of thanks for important suggestions goes to Konstantin Käfer who implemented a nice similar module node-zlib (https://github.com/kkaefer/node-zlib) earlier than me.
  • Oleg Kertanov.

Author

Egor Egorov me@egorfine.com

FAQs

Package last updated on 06 Nov 2011

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