gzip-size (6.0.0)

Published 2026-02-24 13:57:31 +00:00 by atheaadmin

Installation

registry=
npm install gzip-size@6.0.0
"gzip-size": "6.0.0"

About this package

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<number> with 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<number> with the size of the file.

path

Type: string

gzipSize.fileSync(path, options?)

Returns the size of the file.


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Dependencies

Dependencies

ID Version
duplexer ^0.1.2

Development Dependencies

ID Version
ava ^2.4.0
p-event ^4.2.0
tsd ^0.13.1
xo ^0.34.2

Keywords

app tool zlib gzip compressed size string buffer
Details
npm
2026-02-24 13:57:31 +00:00
0
Sindre Sorhus
MIT
latest
3.0 KiB
Assets (1)
Versions (1) View all
6.0.0 2026-02-24