MCPcopy Create free account
hub / github.com/TruthHun/BookStack / Inflate

Function Inflate

static/word2md/mammoth.browser.js:17495–17549  ·  view source on GitHub ↗

* new Inflate(options) * - options (Object): zlib inflate options. * * Creates new inflator instance with specified params. Throws exception * on bad params. Supported options: * * - `windowBits` * - `dictionary` * * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advance

(options)

Source from the content-addressed store, hash-verified

17493 * ```
17494 **/
17495function Inflate(options) {
17496 if (!(this instanceof Inflate)) return new Inflate(options);
17497
17498 this.options = utils.assign({
17499 chunkSize: 16384,
17500 windowBits: 0,
17501 to: ''
17502 }, options || {});
17503
17504 var opt = this.options;
17505
17506 // Force window size for `raw` data, if not set directly,
17507 // because we have no header for autodetect.
17508 if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {
17509 opt.windowBits = -opt.windowBits;
17510 if (opt.windowBits === 0) { opt.windowBits = -15; }
17511 }
17512
17513 // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
17514 if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&
17515 !(options && options.windowBits)) {
17516 opt.windowBits += 32;
17517 }
17518
17519 // Gzip header has no info about windows size, we can do autodetect only
17520 // for deflate. So, if window size not set, force it to max when gzip possible
17521 if ((opt.windowBits > 15) && (opt.windowBits < 48)) {
17522 // bit 3 (16) -> gzipped data
17523 // bit 4 (32) -> autodetect gzip/deflate
17524 if ((opt.windowBits & 15) === 0) {
17525 opt.windowBits |= 15;
17526 }
17527 }
17528
17529 this.err = 0; // error code, if happens (0 = Z_OK)
17530 this.msg = ''; // error message
17531 this.ended = false; // used to avoid multiple onEnd() calls
17532 this.chunks = []; // chunks of compressed data
17533
17534 this.strm = new ZStream();
17535 this.strm.avail_out = 0;
17536
17537 var status = zlib_inflate.inflateInit2(
17538 this.strm,
17539 opt.windowBits
17540 );
17541
17542 if (status !== c.Z_OK) {
17543 throw new Error(msg[status]);
17544 }
17545
17546 this.header = new GZheader();
17547
17548 zlib_inflate.inflateGetHeader(this.strm, this.header);
17549}
17550
17551/**
17552 * Inflate#push(data[, mode]) -> Boolean

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected