- Notifications
You must be signed in to change notification settings - Fork55
foliojs/brotli.js
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Brotli.js is port of theBrotli compression algorithm (as used in theWOFF2 font format) to JavaScript. The decompressor is hand ported, and the compressor is portedwith Emscripten. The original C++ source code can be foundhere.
Install using npm.
npm install brotliIf you want to use brotli in the browser, you should use a bundler to build it.
In node, or in bundlers, you can load brotli in the standard way:
varbrotli=require('brotli');
You can also require just thedecompress function or just thecompress function, which is useful for browser builds.For example, here's how you'd require just thedecompress function.
vardecompress=require('brotli/decompress');
Decompresses the given buffer to produce the original input to the compressor.TheoutSize parameter is optional, and will be computed by the decompressorif not provided. Inside a WOFF2 file, this can be computed from the WOFF2 directory.
// decode a buffer where the output size is knownbrotli.decompress(compressedData,uncompressedLength);// decode a buffer where the output size is not knownbrotli.decompress(fs.readFileSync('compressed.bin'));
Compresses the given buffer. Pass optional parameters as the second argument.
// encode a buffer of binary databrotli.compress(fs.readFileSync('myfile.bin'));// encode some data with options (default options shown)brotli.compress(fs.readFileSync('myfile.bin'),{mode:0,// 0 = generic, 1 = text, 2 = font (WOFF2)quality:11,// 0 - 11lgwin:22,// window sizedictionary:''});
MIT
About
A JavaScript port of the Brotli compression algorithm, as used in WOFF2
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.