gzip-size
Get the gzipped size of a string or buffer
Last updated 5 months ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gzip-size 
SYNC missed versions from official npm registry.

gzip-size Build Status

Get the gzipped size of a string or buffer

Install

$ npm install gzip-size

Usage

const gzipSize = require('gzip-size');

const text = '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(text.length);
//=> 191

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

API

gzipSize(input, [options])

Returns a Promise for the size.

gzipSize.sync(input, [options])

Returns the size.

input

Type: string Buffer

options

Type: Object

Any zlib option.

gzipSize.stream([options])

Returns a stream.PassThrough. The stream emits a gzip-size event and has a gzipSize property.

gzipSize.file(path, [options])

Returns a Promise for the size of the file.

path

Type: string

gzipSize.fileSync(path, [options])

Returns the size of the file.

Related

License

MIT © Sindre Sorhus

Current Tags

  • 5.1.1                                ...           latest (5 months ago)

16 Versions

  • 5.1.1                                ...           5 months ago
  • 5.1.0                                ...           6 months ago
  • 5.0.0                                ...           a year ago
  • 4.1.0                                ...           2 years ago
  • 4.0.1                                ...           2 years ago
  • 4.0.0                                ...           2 years ago
  • 3.0.0                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.3                                ...           4 years ago
  • 2.0.2                                ...           4 years ago
  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.0                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 5,125
This Week 23,545
This Month 163,282
Last Day 18,420
Last Week 104,960
Last Month 426,791
Dependencies (2)
Dev Dependencies (4)
Dependents (768)

Copyright 2014 - 2016 © taobao.org |