1. gzip-size
Get the gzipped size of a string or buffer
gzip-size
Package: gzip-size
Created by: sindresorhus
Last modified: Sat, 18 Jun 2022 18:32:42 GMT
Version: 7.0.0
License: MIT
Downloads: 48,499,760
Repository: https://github.com/sindresorhus/gzip-size

Install

npm install gzip-size
yarn add gzip-size

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.


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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code