A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Hopding/brotli.js below:

Hopding/brotli.js: A JavaScript port of the Brotli compression algorithm, as used in WOFF2

This project is a fork of https://github.com/foliojs/brotli.js created for use in https://github.com/Hopding/pdf-lib.

Listed below are changes that have been made in this fork:

Also see

Brotli.js is port of the Brotli compression algorithm (as used in the WOFF2 font format) to JavaScript. The decompressor is hand ported, and the compressor is ported with Emscripten. The original C++ source code can be found here.

To install the latest stable version:

# With npm
npm install --save @pdf-lib/brotli.js

# With yarn
yarn add @pdf-lib/brotli.js

This assumes you're using npm or yarn as your package manager.

You can build this fork using Rollup for use in the browser, or other JS environments, if you are not using a package manager.

In node, or in browserify, you can load brotli in the standard way:

// ES6
import brotli from 'brotli';

// CommonJS
const brotli = require('brotli');

You can also import just the decompress of compress functions. For example, here's how you'd import just the decompress function.

// ES6
import decompress from 'brotli/decompress';

// CommonJS
const decompress = require('brotli/decompress');
brotli.decompress(buffer, [outSize])

Decompresses the given buffer to produce the original input to the compressor. The outSize parameter is optional, and will be computed by the decompressor if not provided. Inside a WOFF2 file, this can be computed from the WOFF2 directory.

// decode a buffer where the output size is known
brotli.decompress(compressedData, uncompressedLength);

// decode a buffer where the output size is not known
brotli.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 data
brotli.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 - 11
  lgwin: 22 // window size
});

MIT


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4