brotli-fsize

1.0.3 • Public • Published

brotli-fsize Build Status

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)

Package Sidebar

Install

npm i brotli-fsize

Weekly Downloads

624

Version

1.0.3

License

MIT

Unpacked Size

5.81 kB

Total Files

5

Last publish

Collaborators

  • mannil