Get the brotli-compressed size of a string or buffer
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
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));
//=> 134Returns a Promise for the size.
Returns the size.
Type: string Buffer
Type: Object
Any brotli option.
Returns a stream.PassThrough. The stream emits a brotli-fsize event and has a brotliSize property.
Returns a Promise for the size of the file.
Type: string
Returns the size of the file.
Inspired by gzip-size
MIT © Developmint (Alexander Lichter)