🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

brotli-size

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brotli-size

Get the brotli compressed size of a string or buffer

4.0.0
latest
Version published
Weekly downloads
371K
0.8%
Maintainers
1
Weekly downloads
 
Created

What is brotli-size?

The brotli-size npm package is used to calculate the Brotli-compressed size of a given string or buffer. Brotli is a compression algorithm developed by Google that is particularly effective for web content compression.

What are brotli-size's main functionalities?

Calculate Brotli size of a string

This feature allows you to calculate the Brotli-compressed size of a given string synchronously. The code sample demonstrates how to import the brotli-size package, define a string, and then calculate and log its Brotli-compressed size.

const brotliSize = require('brotli-size');
const input = 'Hello, world!';
const size = brotliSize.sync(input);
console.log(`Brotli size: ${size} bytes`);

Calculate Brotli size of a buffer

This feature allows you to calculate the Brotli-compressed size of a given buffer synchronously. The code sample demonstrates how to import the brotli-size package, create a buffer from a string, and then calculate and log its Brotli-compressed size.

const brotliSize = require('brotli-size');
const input = Buffer.from('Hello, world!');
const size = brotliSize.sync(input);
console.log(`Brotli size: ${size} bytes`);

Asynchronous calculation of Brotli size

This feature allows you to calculate the Brotli-compressed size of a given string asynchronously. The code sample demonstrates how to import the brotli-size package, define a string, and then calculate and log its Brotli-compressed size using a promise.

const brotliSize = require('brotli-size');
const input = 'Hello, world!';
brotliSize(input).then(size => {
  console.log(`Brotli size: ${size} bytes`);
});

Other packages similar to brotli-size

FAQs

Package last updated on 08 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts