gzip-size
v7.0.0
Published
Get the gzipped size of a string or buffer
Downloads
49,976,154
Maintainers
Readme
gzip-size
Get the gzipped size of a string or buffer
Install
npm install gzip-size
Usage
import {gzipSize, gzipSizeSync} from '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(gzipSizeSync(text));
//=> 78
API
gzipSize(input, options?)
Returns a Promise<number>
with the size.
gzipSizeSync(input, options?)
Returns the size.
input
Type: string | Buffer
options
Type: object
Any zlib
option.
gzipSizeFromFile(path, options?)
Returns a Promise<number>
with the size of the file.
path
Type: string
gzipSizeFromFileSync(path, options?)
Returns the size of the file.
gzipSizeStream(options?)
Returns a stream.PassThrough
. The stream emits a gzip-size
event and has a gzipSize
property.
Related
- gzip-size-cli - CLI for this module