New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gzipped

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gzipped - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

Makefile

26

index.js
var ReadableStream = require('stream').Readable;
var filesize = require('filesize');
var colors = require('chalk');
var zlib = require('zlib');
function displayStats(original, compressed, ratio) {
console.log(colors.yellow('Original size:'), colors.green(filesize(original)));
console.log(colors.yellow('Compressed size:'), colors.green(filesize(compressed)));
console.log(colors.yellow('Compression ratio:'), colors.green((ratio * 100).toFixed(2) + '%'));
}
function calculate(buffer) {
function calculate(buffer, cb) {
var gzipped = zlib.gzip(buffer, function (err, gzipped) {
if (err) throw err;
if (err) return cb(err);
displayStats(buffer.length, gzipped.length, buffer.length / gzipped.length);
cb(null, {
original: buffer.length,
compressed: gzipped.length,
ratio: gzipped.length / buffer.length
});
});
}
module.exports.calculate = function (stream) {
module.exports.calculate = function (stream, cb) {
var buffers = [];

@@ -28,4 +24,8 @@

stream.on('end', function () {
calculate(Buffer.concat(buffers));
calculate(Buffer.concat(buffers), cb);
});
stream.on('error', function (err) {
cb(err);
});
};
{
"name": "gzipped",
"version": "0.0.3",
"version": "0.0.4",
"description": "Command line utility to calculate gzip compression savings",

@@ -5,0 +5,0 @@ "main": "index.js",

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