• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..21-May-2021-

build/H03-May-2022-

dec/H03-May-2022-

enc/H03-May-2022-

node_modules/base64-js/H21-May-2021-8867

package.jsonH A D21-May-2021786 3635

readme.mdH A D21-May-20211.9 KiB6241

readme.md

1# Brotli.js
2
3Brotli.js is port of the [Brotli](http://tools.ietf.org/html/draft-alakuijala-brotli-01) compression algorithm (as used in the [WOFF2](http://www.w3.org/TR/WOFF2/) font format) to JavaScript. The decompressor is hand ported, and the compressor is ported
4with Emscripten.  The original C++ source code can be found [here](http://github.com/google/brotli).
5
6## Installation and usage
7
8Install using npm.
9
10    npm install brotli
11
12If you want to use brotli in the browser, you should use [Browserify](http://browserify.org/) to build it.
13
14In node, or in browserify, you can load brotli in the standard way:
15
16```javascript
17var brotli = require('brotli');
18```
19
20You can also require just the `decompress` function or just the `compress` function, which is useful for browserify builds.
21For example, here's how you'd require just the `decompress` function.
22
23```javascript
24var decompress = require('brotli/decompress');
25```
26
27## API
28
29### brotli.decompress(buffer, [outSize])
30
31Decompresses the given buffer to produce the original input to the compressor.
32The `outSize` parameter is optional, and will be computed by the decompressor
33if not provided. Inside a WOFF2 file, this can be computed from the WOFF2 directory.
34
35```javascript
36// decode a buffer where the output size is known
37brotli.decompress(compressedData, uncompressedLength);
38
39// decode a buffer where the output size is not known
40brotli.decompress(fs.readFileSync('compressed.bin'));
41```
42
43### brotli.compress(buffer, isText = false)
44
45Compresses the given buffer. Pass optional parameters as the second argument.
46
47```javascript
48// encode a buffer of binary data
49brotli.compress(fs.readFileSync('myfile.bin'));
50
51// encode some data with options (default options shown)
52brotli.compress(fs.readFileSync('myfile.bin'), {
53  mode: 0, // 0 = generic, 1 = text, 2 = font (WOFF2)
54  quality: 11, // 0 - 11
55  lgwin: 22 // window size
56});
57```
58
59## License
60
61MIT
62