brotli-fsize
v1.0.3
Published
Get the brotli-compressed size of a string or buffer
Downloads
1,832
Maintainers
Readme
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
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.
brotliSize.stream([options])
Returns a 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
MIT © Developmint (Alexander Lichter)