brotlin
A handy CLI/API for Brotli compression based on npm/brotli. Helps you to convert files to Brotli(.br
) format.
![](https://img.shields.io/badge/TypeScript-Ready-blue.svg)
Install
Requires Node >=8.
From npm,
npm i -g brotlin
From Github Package Registry. (Guide).
Type definitions are bundled with this package.
Usage
Quick start
cd my-dir
brotlin compress *
brotlin compress
brotlin compress index.html
brotlin compress style.css --quality 8
A new compressed file ending with .br
will be created for every file feeding in to the CLI.
You can pass in a relative path or an absolute path or a glob pattern.
--help
for help
$ brotlin --help
Usage: brotlin [options] [command]
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
compress [options] [file] Creates a compressed file in the same location. Argument can be relative/absolute/glob
paths [default:*]. Check https://www.npmjs.com/package/brotli to know more about the
following options
--help
for brotlin compress
command:
$ brotlin compress --help
Usage: brotlin compress [options] [file]
Creates a compressed file in the same location. Argument can be relative/absolute/glob paths [default:*]. Check https://www.npmjs.com/package/brotli to know more about the following options
Options:
-m, --mode <number> Brotli compression mode (0 = generic[default], 1 = text, 2 = font (WOFF2))
-q, --quality <number> Compression quality [0 - 11]. [default: 11]
-w, --window <number> Compression window size [default: 22]
-p, --parallel <count> Processes <count> number of files in parallel. [default: 1]
-h, --help output usage information
For knowing more about these options, see npm/brotli.
One more example
cd dist
brotlin compress **/*
APIs
import { compression } from 'brotlin';
const { compression } = require('brotlin');
compression({
path: '*.html',
parallelJobCount: 1,
mode: 0,
quality: 11,
windowSize: 22
}).then(files => console.log(`Compressed ${files.length} files`));
Licence
MIT © Vajahath Ahmed