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

gzip-size

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gzip-size - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

30

cli.js

@@ -6,10 +6,19 @@ #!/usr/bin/env node

var concat = require('concat-stream');
var input = process.argv[2];
var pkg = require('./package.json');
var argv = process.argv.slice(2);
var input = argv[0];
function help() {
console.log('gzip-size <input-file>');
console.log('or');
console.log('cat <input-file> | gzip-size');
console.log('');
console.log('Get the gzipped size of a file');
console.log([
'',
' ' + pkg.description,
'',
' Usage',
' gzip-size <file>',
' cat <file> | gzip-size',
'',
' Example',
' gzip-size index.js',
' 211'
].join('\n'));
}

@@ -21,3 +30,3 @@

if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) {
if (argv.indexOf('--help') !== -1) {
help();

@@ -27,4 +36,4 @@ return;

if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
console.log(require('./package').version);
if (argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;

@@ -35,3 +44,4 @@ }

if (!input) {
return help();
help();
return;
}

@@ -38,0 +48,0 @@

@@ -7,3 +7,4 @@ 'use strict';

if (!str) {
return cb(err, 0);
cb(null, 0);
return;
}

@@ -13,3 +14,4 @@

if (err) {
return cb(err, 0);
cb(err, 0);
return;
}

@@ -16,0 +18,0 @@

{
"name": "gzip-size",
"version": "0.2.0",
"version": "1.0.0",
"description": "Get the gzipped size of a string or buffer",

@@ -19,3 +19,3 @@ "license": "MIT",

"scripts": {
"test": "mocha"
"test": "node test.js"
},

@@ -43,4 +43,4 @@ "files": [

"devDependencies": {
"mocha": "*"
"ava": "0.0.3"
}
}

@@ -8,3 +8,3 @@ # gzip-size [![Build Status](https://travis-ci.org/sindresorhus/gzip-size.svg?branch=master)](https://travis-ci.org/sindresorhus/gzip-size)

```bash
```sh
$ npm install --save gzip-size

@@ -18,3 +18,2 @@ ```

var gzipSize = require('gzip-size');
var string = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.';

@@ -37,3 +36,3 @@

*Required*
Type: `String`|`Buffer`
Type: `string`, `buffer`

@@ -43,9 +42,12 @@ #### callback(err, size)

*Required*
Type: `Function`
Type: `function`
### gzipSize.sync(input)
Returns the size.
#### input
*Required*
Type: `String`|`Buffer`
Returns: size
Type: `string`, `buffer`

@@ -55,28 +57,23 @@

You can also use it as a CLI app by installing it globally:
```bash
```sh
$ npm install --global gzip-size
```
#### Usage
```bash
```sh
$ gzip-size --help
gzip-size <input-file>
or
cat <input-file> | gzip-size
Usage
gzip-size <file>
cat <file> | gzip-size
Example
gzip-size index.js
211
```
#### Example
### Tip
```bash
$ gzip-size jquery.min.js
29344
```
Combine it with [pretty-bytes](https://github.com/sindresorhus/pretty-bytes) to get a human readable output:
or with [pretty-bytes](https://github.com/sindresorhus/pretty-bytes):
```bash
```sh
$ pretty-bytes $(gzip-size jquery.min.js)

@@ -89,2 +86,2 @@ 29.34 kB

[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](http://sindresorhus.com)
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