Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_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;
}
}