Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/gzip-size
Get the gzipped size of a string or buffer
https://github.com/sindresorhus/gzip-size
Last synced: 29 days ago
JSON representation
Get the gzipped size of a string or buffer
- Host: GitHub
- URL: https://github.com/sindresorhus/gzip-size
- Owner: sindresorhus
- License: mit
- Created: 2014-02-28T19:55:14.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2021-11-23T07:55:36.000Z (almost 3 years ago)
- Last Synced: 2024-04-14T09:53:11.002Z (7 months ago)
- Language: JavaScript
- Size: 42 KB
- Stars: 167
- Watchers: 7
- Forks: 20
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
- Security: .github/security.md
Awesome Lists containing this project
- awesome-github-star - gzip-size
README
# gzip-size
> Get the gzipped size of a string or buffer
## Install
```sh
npm install gzip-size
```## Usage
```js
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);
//=> 191console.log(gzipSizeSync(text));
//=> 78
```## API
### gzipSize(input, options?)
Returns a `Promise` with the size.
### gzipSizeSync(input, options?)
Returns the size.
#### input
Type: `string | Buffer`
#### options
Type: `object`
Any [`zlib` option](https://nodejs.org/api/zlib.html#zlib_class_options).
### gzipSizeFromFile(path, options?)
Returns a `Promise` with the size of the file.
#### path
Type: `string`
### gzipSizeFromFileSync(path, options?)
Returns the size of the file.
### gzipSizeStream(options?)
Returns a [`stream.PassThrough`](https://nodejs.org/api/stream.html#stream_class_stream_passthrough). The stream emits a `gzip-size` event and has a `gzipSize` property.
## Related
- [gzip-size-cli](https://github.com/sindresorhus/gzip-size-cli) - CLI for this module
---
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.