https://github.com/developmint/brotli-fsize
Get the brotli-compressed size of a string or buffer
https://github.com/developmint/brotli-fsize
Last synced: 4 months ago
JSON representation
Get the brotli-compressed size of a string or buffer
- Host: GitHub
- URL: https://github.com/developmint/brotli-fsize
- Owner: Developmint
- License: mit
- Created: 2019-01-18T23:34:41.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-22T11:34:24.000Z (about 7 years ago)
- Last Synced: 2025-02-18T19:40:11.343Z (about 1 year ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# brotli-fsize [](https://travis-ci.org/Developmint/brotli-fsize)
> Get the brotli-compressed size of a string or buffer
## Install
**Attention:** This module is based on the **native** Brotli support, starting with
Node version **11.7.0**. Therefore it will only work with Node version equal to or higher.
```
$ npm install brotli-fsize
```
## Usage
```js
const brotliSize = require('brotli-fsize');
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(brotliSize.sync(text));
//=> 134
```
## API
### brotliSize(input, [options])
Returns a `Promise` for the size.
### brotliSize.sync(input, [options])
Returns the size.
#### input
Type: `string` `Buffer`
#### options
Type: `Object`
Any [`brotli` option](https://nodejs.org/api/zlib.html#zlib_class_brotlioptions).
### brotliSize.stream([options])
Returns a [`stream.PassThrough`](https://nodejs.org/api/stream.html#stream_class_stream_passthrough). The stream emits a `brotli-fsize` event and has a `brotliSize` property.
### brotliSize.file(path, [options])
Returns a `Promise` for the size of the file.
#### path
Type: `string`
### brotliSize.fileSync(path, [options])
Returns the size of the file.
## License
Inspired by [gzip-size](https://github.com/sindresorhus/gzip-size#readme)
MIT © Developmint (Alexander Lichter)