How to use the brotli/decompress function in brotli

To help you get started, we’ve selected a few brotli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github foliojs / fontkit / src / WOFF2Font.js View on Github external
_decompress() {
    // decompress data and setup table offsets if we haven't already
    if (!this._decompressed) {
      this.stream.pos = this._dataPos;
      let buffer = this.stream.readBuffer(this.directory.totalCompressedSize);

      let decompressedSize = 0;
      for (let tag in this.directory.tables) {
        let entry = this.directory.tables[tag];
        entry.offset = decompressedSize;
        decompressedSize += (entry.transformLength != null) ? entry.transformLength : entry.length;
      }

      let decompressed = brotli(buffer, decompressedSize);
      if (!decompressed) {
        throw new Error('Error decoding compressed data in WOFF2');
      }

      this.stream = new r.DecodeStream(new Buffer(decompressed));
      this._decompressed = true;
    }
  }

brotli

A port of the Brotli compression algorithm as used in WOFF2

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis