https://github.com/ngryman/zopfli-size
Get the gzipped size of a string or buffer using Zopfli.
https://github.com/ngryman/zopfli-size
gzip size zopfli
Last synced: about 1 year ago
JSON representation
Get the gzipped size of a string or buffer using Zopfli.
- Host: GitHub
- URL: https://github.com/ngryman/zopfli-size
- Owner: ngryman
- License: mit
- Created: 2017-04-23T14:05:18.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-06T08:02:38.000Z (almost 9 years ago)
- Last Synced: 2025-01-28T05:28:17.046Z (over 1 year ago)
- Topics: gzip, size, zopfli
- Language: JavaScript
- Size: 37.1 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# zopfli-size
> Get the gzipped size of a string or buffer using Zopfli.
[![travis][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url]
[travis-image]: https://img.shields.io/travis/ngryman/zopfli-size.svg?style=flat
[travis-url]: https://travis-ci.org/ngryman/zopfli-size
[codecov-image]: https://img.shields.io/codecov/c/github/ngryman/zopfli-size.svg
[codecov-url]: https://codecov.io/github/ngryman/zopfli-size
## Usage
```javascript
var zopfliSize = require('zopfli-size');
var string = '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(string.length);
//=> 191
console.log(zopfliSize.sync(string));
//=> 148
```
## API
### `zopfliSize(input)`
Return a `Promise` that is resolved with the gzip size of `input. `input` can be a `string` or `Buffer`.
### `zopfliSize.sync(input)`
Return the gzip of `input` size synchronously. `input` can be a `string` or `Buffer`.
### `zopfliSize.strean()`
Return a passthrough stream. The stream emits a `gzip-size` event and has a `gzipSize` property.
## Related
- [zopfli-size-cli](https://github.com/ngryman/zopfli-size-cli) CLI for this module.
## License
MIT © [Nicolas Gryman](http://ngryman.sh)