Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A JavaScript port of the Brotli compression algorithm, as used in WOFF2

NotificationsYou must be signed in to change notification settings

foliojs/brotli.js

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.

Installation and usage

Install using npm.

npm install brotli

If 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');

API

brotli.decompress(buffer, [outSize])

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'));

brotli.compress(buffer, isText = false)

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:''});

License

MIT

About

A JavaScript port of the Brotli compression algorithm, as used in WOFF2

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp