JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14838222
  • Score
    100M100P100Q219882F
  • License MIT

Get the gzipped size of a string or buffer

Package Exports

  • gzip-size

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gzip-size) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gzip-size Build Status

Get the gzipped size of a string or buffer

Install

$ npm install --save gzip-size

Usage

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.';

console.log(string.length);
//=> 191

console.log(gzipSize.sync(string));
//=> 78

API

gzipSize(input, callback)

input

Required
Type: String|Buffer

callback(err, size)

Required
Type: Function

gzipSize.sync(input)

Required
Type: String|Buffer
Returns: size

CLI

You can also use it as a CLI app by installing it globally:

$ npm install --global gzip-size

Usage

$ gzip-size --help

gzip-size <input-file>
or
cat <input-file> | gzip-size

Example

$ gzip-size jquery.min.js
29344

or with pretty-bytes:

$ pretty-bytes $(gzip-size jquery.min.js)
29.34 kB

License

MIT © Sindre Sorhus