Skip to content

Get the brotli-compressed size of a string or buffer

License

Notifications You must be signed in to change notification settings

Developmint/brotli-fsize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Get the brotli-compressed size of a string or buffer

Resources

License

Stars

Watchers

Forks

Packages

No packages published