browser files rebuild

This commit is contained in:
Vitaly Puzrin 2016-02-17 12:02:05 +03:00
parent 02af90ea69
commit a25bfa041a
6 changed files with 440 additions and 424 deletions

392
dist/pako.js vendored

File diff suppressed because it is too large Load diff

6
dist/pako.min.js vendored

File diff suppressed because one or more lines are too long

304
dist/pako_deflate.js vendored
View file

@ -1,4 +1,4 @@
/* pako 0.2.8 nodeca/pako */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.pako = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ /* pako 1.0.0 nodeca/pako */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.pako = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict'; 'use strict';
@ -40,28 +40,28 @@ exports.shrinkBuf = function (buf, size) {
var fnTyped = { var fnTyped = {
arraySet: function (dest, src, src_offs, len, dest_offs) { arraySet: function (dest, src, src_offs, len, dest_offs) {
if (src.subarray && dest.subarray) { if (src.subarray && dest.subarray) {
dest.set(src.subarray(src_offs, src_offs+len), dest_offs); dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
return; return;
} }
// Fallback to ordinary array // Fallback to ordinary array
for (var i=0; i<len; i++) { for (var i = 0; i < len; i++) {
dest[dest_offs + i] = src[src_offs + i]; dest[dest_offs + i] = src[src_offs + i];
} }
}, },
// Join array of chunks to single array. // Join array of chunks to single array.
flattenChunks: function(chunks) { flattenChunks: function (chunks) {
var i, l, len, pos, chunk, result; var i, l, len, pos, chunk, result;
// calculate data length // calculate data length
len = 0; len = 0;
for (i=0, l=chunks.length; i<l; i++) { for (i = 0, l = chunks.length; i < l; i++) {
len += chunks[i].length; len += chunks[i].length;
} }
// join chunks // join chunks
result = new Uint8Array(len); result = new Uint8Array(len);
pos = 0; pos = 0;
for (i=0, l=chunks.length; i<l; i++) { for (i = 0, l = chunks.length; i < l; i++) {
chunk = chunks[i]; chunk = chunks[i];
result.set(chunk, pos); result.set(chunk, pos);
pos += chunk.length; pos += chunk.length;
@ -73,12 +73,12 @@ var fnTyped = {
var fnUntyped = { var fnUntyped = {
arraySet: function (dest, src, src_offs, len, dest_offs) { arraySet: function (dest, src, src_offs, len, dest_offs) {
for (var i=0; i<len; i++) { for (var i = 0; i < len; i++) {
dest[dest_offs + i] = src[src_offs + i]; dest[dest_offs + i] = src[src_offs + i];
} }
}, },
// Join array of chunks to single array. // Join array of chunks to single array.
flattenChunks: function(chunks) { flattenChunks: function (chunks) {
return [].concat.apply([], chunks); return [].concat.apply([], chunks);
} }
}; };
@ -118,18 +118,18 @@ var utils = require('./common');
var STR_APPLY_OK = true; var STR_APPLY_OK = true;
var STR_APPLY_UIA_OK = true; var STR_APPLY_UIA_OK = true;
try { String.fromCharCode.apply(null, [0]); } catch(__) { STR_APPLY_OK = false; } try { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }
try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch(__) { STR_APPLY_UIA_OK = false; } try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }
// Table with utf8 lengths (calculated by first byte of sequence) // Table with utf8 lengths (calculated by first byte of sequence)
// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS, // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
// because max possible codepoint is 0x10ffff // because max possible codepoint is 0x10ffff
var _utf8len = new utils.Buf8(256); var _utf8len = new utils.Buf8(256);
for (var q=0; q<256; q++) { for (var q = 0; q < 256; q++) {
_utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1); _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);
} }
_utf8len[254]=_utf8len[254]=1; // Invalid sequence start _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start
// convert string to array (typed, when possible) // convert string to array (typed, when possible)
@ -139,8 +139,8 @@ exports.string2buf = function (str) {
// count binary size // count binary size
for (m_pos = 0; m_pos < str_len; m_pos++) { for (m_pos = 0; m_pos < str_len; m_pos++) {
c = str.charCodeAt(m_pos); c = str.charCodeAt(m_pos);
if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) { if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
c2 = str.charCodeAt(m_pos+1); c2 = str.charCodeAt(m_pos + 1);
if ((c2 & 0xfc00) === 0xdc00) { if ((c2 & 0xfc00) === 0xdc00) {
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
m_pos++; m_pos++;
@ -153,10 +153,10 @@ exports.string2buf = function (str) {
buf = new utils.Buf8(buf_len); buf = new utils.Buf8(buf_len);
// convert // convert
for (i=0, m_pos = 0; i < buf_len; m_pos++) { for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
c = str.charCodeAt(m_pos); c = str.charCodeAt(m_pos);
if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) { if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
c2 = str.charCodeAt(m_pos+1); c2 = str.charCodeAt(m_pos + 1);
if ((c2 & 0xfc00) === 0xdc00) { if ((c2 & 0xfc00) === 0xdc00) {
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
m_pos++; m_pos++;
@ -196,7 +196,7 @@ function buf2binstring(buf, len) {
} }
var result = ''; var result = '';
for (var i=0; i < len; i++) { for (var i = 0; i < len; i++) {
result += String.fromCharCode(buf[i]); result += String.fromCharCode(buf[i]);
} }
return result; return result;
@ -204,15 +204,15 @@ function buf2binstring(buf, len) {
// Convert byte array to binary string // Convert byte array to binary string
exports.buf2binstring = function(buf) { exports.buf2binstring = function (buf) {
return buf2binstring(buf, buf.length); return buf2binstring(buf, buf.length);
}; };
// Convert binary string (typed, when possible) // Convert binary string (typed, when possible)
exports.binstring2buf = function(str) { exports.binstring2buf = function (str) {
var buf = new utils.Buf8(str.length); var buf = new utils.Buf8(str.length);
for (var i=0, len=buf.length; i < len; i++) { for (var i = 0, len = buf.length; i < len; i++) {
buf[i] = str.charCodeAt(i); buf[i] = str.charCodeAt(i);
} }
return buf; return buf;
@ -227,16 +227,16 @@ exports.buf2string = function (buf, max) {
// Reserve max possible length (2 words per char) // Reserve max possible length (2 words per char)
// NB: by unknown reasons, Array is significantly faster for // NB: by unknown reasons, Array is significantly faster for
// String.fromCharCode.apply than Uint16Array. // String.fromCharCode.apply than Uint16Array.
var utf16buf = new Array(len*2); var utf16buf = new Array(len * 2);
for (out=0, i=0; i<len;) { for (out = 0, i = 0; i < len;) {
c = buf[i++]; c = buf[i++];
// quick process ascii // quick process ascii
if (c < 0x80) { utf16buf[out++] = c; continue; } if (c < 0x80) { utf16buf[out++] = c; continue; }
c_len = _utf8len[c]; c_len = _utf8len[c];
// skip 5 & 6 byte codes // skip 5 & 6 byte codes
if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len-1; continue; } if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }
// apply mask on first byte // apply mask on first byte
c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;
@ -268,14 +268,14 @@ exports.buf2string = function (buf, max) {
// //
// buf[] - utf8 bytes array // buf[] - utf8 bytes array
// max - length limit (mandatory); // max - length limit (mandatory);
exports.utf8border = function(buf, max) { exports.utf8border = function (buf, max) {
var pos; var pos;
max = max || buf.length; max = max || buf.length;
if (max > buf.length) { max = buf.length; } if (max > buf.length) { max = buf.length; }
// go back from last position, until start of sequence found // go back from last position, until start of sequence found
pos = max-1; pos = max - 1;
while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; } while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }
// Fuckup - very small and broken sequence, // Fuckup - very small and broken sequence,
@ -335,10 +335,10 @@ module.exports = adler32;
function makeTable() { function makeTable() {
var c, table = []; var c, table = [];
for (var n =0; n < 256; n++) { for (var n = 0; n < 256; n++) {
c = n; c = n;
for (var k =0; k < 8; k++) { for (var k = 0; k < 8; k++) {
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)); c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
} }
table[n] = c; table[n] = c;
} }
@ -354,7 +354,7 @@ function crc32(crc, buf, len, pos) {
var t = crcTable, var t = crcTable,
end = pos + len; end = pos + len;
crc = crc ^ (-1); crc ^= -1;
for (var i = pos; i < end; i++) { for (var i = pos; i < end; i++) {
crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF]; crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
@ -373,7 +373,7 @@ var utils = require('../utils/common');
var trees = require('./trees'); var trees = require('./trees');
var adler32 = require('./adler32'); var adler32 = require('./adler32');
var crc32 = require('./crc32'); var crc32 = require('./crc32');
var msg = require('./messages'); var msg = require('./messages');
/* Public constants ==========================================================*/ /* Public constants ==========================================================*/
/* ===========================================================================*/ /* ===========================================================================*/
@ -446,7 +446,7 @@ var D_CODES = 30;
/* number of distance codes */ /* number of distance codes */
var BL_CODES = 19; var BL_CODES = 19;
/* number of codes used to transfer the bit lengths */ /* number of codes used to transfer the bit lengths */
var HEAP_SIZE = 2*L_CODES + 1; var HEAP_SIZE = 2 * L_CODES + 1;
/* maximum heap size */ /* maximum heap size */
var MAX_BITS = 15; var MAX_BITS = 15;
/* All codes must not exceed MAX_BITS bits */ /* All codes must not exceed MAX_BITS bits */
@ -512,7 +512,7 @@ function flush_pending(strm) {
} }
function flush_block_only (s, last) { function flush_block_only(s, last) {
trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last); trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);
s.block_start = s.strstart; s.block_start = s.strstart;
flush_pending(s.strm); flush_pending(s.strm);
@ -782,7 +782,7 @@ function fill_window(s) {
//#endif //#endif
while (s.insert) { while (s.insert) {
/* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */ /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH-1]) & s.hash_mask; s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
s.prev[str & s.w_mask] = s.head[s.ins_h]; s.prev[str & s.w_mask] = s.head[s.ins_h];
s.head[s.ins_h] = str; s.head[s.ins_h] = str;
@ -1046,7 +1046,7 @@ function deflate_fast(s, flush) {
/***/ /***/
} }
} }
s.insert = ((s.strstart < (MIN_MATCH-1)) ? s.strstart : MIN_MATCH-1); s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);
if (flush === Z_FINISH) { if (flush === Z_FINISH) {
/*** FLUSH_BLOCK(s, 1); ***/ /*** FLUSH_BLOCK(s, 1); ***/
flush_block_only(s, true); flush_block_only(s, true);
@ -1109,10 +1109,10 @@ function deflate_slow(s, flush) {
*/ */
s.prev_length = s.match_length; s.prev_length = s.match_length;
s.prev_match = s.match_start; s.prev_match = s.match_start;
s.match_length = MIN_MATCH-1; s.match_length = MIN_MATCH - 1;
if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match && if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&
s.strstart - hash_head <= (s.w_size-MIN_LOOKAHEAD)/*MAX_DIST(s)*/) { s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {
/* To simplify the code, we prevent matches with the string /* To simplify the code, we prevent matches with the string
* of window index 0 (in particular we have to avoid a match * of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file). * of the string with itself at the start of the input file).
@ -1126,7 +1126,7 @@ function deflate_slow(s, flush) {
/* If prev_match is also MIN_MATCH, match_start is garbage /* If prev_match is also MIN_MATCH, match_start is garbage
* but we will ignore the current match anyway. * but we will ignore the current match anyway.
*/ */
s.match_length = MIN_MATCH-1; s.match_length = MIN_MATCH - 1;
} }
} }
/* If there was a match at the previous step and the current /* If there was a match at the previous step and the current
@ -1140,13 +1140,13 @@ function deflate_slow(s, flush) {
/***_tr_tally_dist(s, s.strstart - 1 - s.prev_match, /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,
s.prev_length - MIN_MATCH, bflush);***/ s.prev_length - MIN_MATCH, bflush);***/
bflush = trees._tr_tally(s, s.strstart - 1- s.prev_match, s.prev_length - MIN_MATCH); bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);
/* Insert in hash table all strings up to the end of the match. /* Insert in hash table all strings up to the end of the match.
* strstart-1 and strstart are already inserted. If there is not * strstart-1 and strstart are already inserted. If there is not
* enough lookahead, the last two strings are not inserted in * enough lookahead, the last two strings are not inserted in
* the hash table. * the hash table.
*/ */
s.lookahead -= s.prev_length-1; s.lookahead -= s.prev_length - 1;
s.prev_length -= 2; s.prev_length -= 2;
do { do {
if (++s.strstart <= max_insert) { if (++s.strstart <= max_insert) {
@ -1158,7 +1158,7 @@ function deflate_slow(s, flush) {
} }
} while (--s.prev_length !== 0); } while (--s.prev_length !== 0);
s.match_available = 0; s.match_available = 0;
s.match_length = MIN_MATCH-1; s.match_length = MIN_MATCH - 1;
s.strstart++; s.strstart++;
if (bflush) { if (bflush) {
@ -1177,7 +1177,7 @@ function deflate_slow(s, flush) {
*/ */
//Tracevv((stderr,"%c", s->window[s->strstart-1])); //Tracevv((stderr,"%c", s->window[s->strstart-1]));
/*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/ /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
bflush = trees._tr_tally(s, 0, s.window[s.strstart-1]); bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
if (bflush) { if (bflush) {
/*** FLUSH_BLOCK_ONLY(s, 0) ***/ /*** FLUSH_BLOCK_ONLY(s, 0) ***/
@ -1202,11 +1202,11 @@ function deflate_slow(s, flush) {
if (s.match_available) { if (s.match_available) {
//Tracevv((stderr,"%c", s->window[s->strstart-1])); //Tracevv((stderr,"%c", s->window[s->strstart-1]));
/*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/ /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
bflush = trees._tr_tally(s, 0, s.window[s.strstart-1]); bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
s.match_available = 0; s.match_available = 0;
} }
s.insert = s.strstart < MIN_MATCH-1 ? s.strstart : MIN_MATCH-1; s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
if (flush === Z_FINISH) { if (flush === Z_FINISH) {
/*** FLUSH_BLOCK(s, 1); ***/ /*** FLUSH_BLOCK(s, 1); ***/
flush_block_only(s, true); flush_block_only(s, true);
@ -1386,13 +1386,13 @@ function deflate_huff(s, flush) {
* exclude worst case performance for pathological files. Better values may be * exclude worst case performance for pathological files. Better values may be
* found for specific files. * found for specific files.
*/ */
var Config = function (good_length, max_lazy, nice_length, max_chain, func) { function Config(good_length, max_lazy, nice_length, max_chain, func) {
this.good_length = good_length; this.good_length = good_length;
this.max_lazy = max_lazy; this.max_lazy = max_lazy;
this.nice_length = nice_length; this.nice_length = nice_length;
this.max_chain = max_chain; this.max_chain = max_chain;
this.func = func; this.func = func;
}; }
var configuration_table; var configuration_table;
@ -1542,8 +1542,8 @@ function DeflateState() {
// Use flat array of DOUBLE size, with interleaved fata, // Use flat array of DOUBLE size, with interleaved fata,
// because JS does not support effective // because JS does not support effective
this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2); this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);
this.dyn_dtree = new utils.Buf16((2*D_CODES+1) * 2); this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);
this.bl_tree = new utils.Buf16((2*BL_CODES+1) * 2); this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);
zero(this.dyn_ltree); zero(this.dyn_ltree);
zero(this.dyn_dtree); zero(this.dyn_dtree);
zero(this.bl_tree); zero(this.bl_tree);
@ -1553,11 +1553,11 @@ function DeflateState() {
this.bl_desc = null; /* desc. for bit length tree */ this.bl_desc = null; /* desc. for bit length tree */
//ush bl_count[MAX_BITS+1]; //ush bl_count[MAX_BITS+1];
this.bl_count = new utils.Buf16(MAX_BITS+1); this.bl_count = new utils.Buf16(MAX_BITS + 1);
/* number of codes at each bit length for an optimal tree */ /* number of codes at each bit length for an optimal tree */
//int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
this.heap = new utils.Buf16(2*L_CODES+1); /* heap used to build the Huffman trees */ this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */
zero(this.heap); zero(this.heap);
this.heap_len = 0; /* number of elements in the heap */ this.heap_len = 0; /* number of elements in the heap */
@ -1566,7 +1566,7 @@ function DeflateState() {
* The same heap array is used to build all trees. * The same heap array is used to build all trees.
*/ */
this.depth = new utils.Buf16(2*L_CODES+1); //uch depth[2*L_CODES+1]; this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];
zero(this.depth); zero(this.depth);
/* Depth of each subtree used as tie breaker for trees of equal frequency /* Depth of each subtree used as tie breaker for trees of equal frequency
*/ */
@ -2137,9 +2137,9 @@ exports.deflateTune = deflateTune;
'use strict'; 'use strict';
module.exports = { module.exports = {
'2': 'need dictionary', /* Z_NEED_DICT 2 */ 2: 'need dictionary', /* Z_NEED_DICT 2 */
'1': 'stream end', /* Z_STREAM_END 1 */ 1: 'stream end', /* Z_STREAM_END 1 */
'0': '', /* Z_OK 0 */ 0: '', /* Z_OK 0 */
'-1': 'file error', /* Z_ERRNO (-1) */ '-1': 'file error', /* Z_ERRNO (-1) */
'-2': 'stream error', /* Z_STREAM_ERROR (-2) */ '-2': 'stream error', /* Z_STREAM_ERROR (-2) */
'-3': 'data error', /* Z_DATA_ERROR (-3) */ '-3': 'data error', /* Z_DATA_ERROR (-3) */
@ -2206,7 +2206,7 @@ var D_CODES = 30;
var BL_CODES = 19; var BL_CODES = 19;
/* number of codes used to transfer the bit lengths */ /* number of codes used to transfer the bit lengths */
var HEAP_SIZE = 2*L_CODES + 1; var HEAP_SIZE = 2 * L_CODES + 1;
/* maximum heap size */ /* maximum heap size */
var MAX_BITS = 15; var MAX_BITS = 15;
@ -2235,6 +2235,7 @@ var REPZ_3_10 = 17;
var REPZ_11_138 = 18; var REPZ_11_138 = 18;
/* repeat a zero length 11-138 times (7 bits of repeat count) */ /* repeat a zero length 11-138 times (7 bits of repeat count) */
/* eslint-disable comma-spacing,array-bracket-spacing */
var extra_lbits = /* extra bits for each length code */ var extra_lbits = /* extra bits for each length code */
[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]; [0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0];
@ -2246,6 +2247,8 @@ var extra_blbits = /* extra bits for each bit length code */
var bl_order = var bl_order =
[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]; [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];
/* eslint-enable comma-spacing,array-bracket-spacing */
/* The lengths of the bit length codes are sent in order of decreasing /* The lengths of the bit length codes are sent in order of decreasing
* probability, to avoid transmitting the lengths for unused bit length codes. * probability, to avoid transmitting the lengths for unused bit length codes.
*/ */
@ -2259,7 +2262,7 @@ var bl_order =
var DIST_CODE_LEN = 512; /* see definition of array dist_code below */ var DIST_CODE_LEN = 512; /* see definition of array dist_code below */
// !!!! Use flat array insdead of structure, Freq = i*2, Len = i*2+1 // !!!! Use flat array insdead of structure, Freq = i*2, Len = i*2+1
var static_ltree = new Array((L_CODES+2) * 2); var static_ltree = new Array((L_CODES + 2) * 2);
zero(static_ltree); zero(static_ltree);
/* The static literal tree. Since the bit lengths are imposed, there is no /* The static literal tree. Since the bit lengths are imposed, there is no
* need for the L_CODES extra codes used during heap construction. However * need for the L_CODES extra codes used during heap construction. However
@ -2280,7 +2283,7 @@ zero(_dist_code);
* the 15 bit distances. * the 15 bit distances.
*/ */
var _length_code = new Array(MAX_MATCH-MIN_MATCH+1); var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);
zero(_length_code); zero(_length_code);
/* length code for each normalized match length (0 == MIN_MATCH) */ /* length code for each normalized match length (0 == MIN_MATCH) */
@ -2293,7 +2296,7 @@ zero(base_dist);
/* First normalized distance for each code (0 = distance of 1) */ /* First normalized distance for each code (0 = distance of 1) */
var StaticTreeDesc = function (static_tree, extra_bits, extra_base, elems, max_length) { function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {
this.static_tree = static_tree; /* static tree or NULL */ this.static_tree = static_tree; /* static tree or NULL */
this.extra_bits = extra_bits; /* extra bits for each code or NULL */ this.extra_bits = extra_bits; /* extra bits for each code or NULL */
@ -2303,7 +2306,7 @@ var StaticTreeDesc = function (static_tree, extra_bits, extra_base, elems, max_l
// show if `static_tree` has data or dummy - needed for monomorphic objects // show if `static_tree` has data or dummy - needed for monomorphic objects
this.has_stree = static_tree && static_tree.length; this.has_stree = static_tree && static_tree.length;
}; }
var static_l_desc; var static_l_desc;
@ -2311,11 +2314,11 @@ var static_d_desc;
var static_bl_desc; var static_bl_desc;
var TreeDesc = function(dyn_tree, stat_desc) { function TreeDesc(dyn_tree, stat_desc) {
this.dyn_tree = dyn_tree; /* the dynamic tree */ this.dyn_tree = dyn_tree; /* the dynamic tree */
this.max_code = 0; /* largest code with non zero frequency */ this.max_code = 0; /* largest code with non zero frequency */
this.stat_desc = stat_desc; /* the corresponding static tree */ this.stat_desc = stat_desc; /* the corresponding static tree */
}; }
@ -2328,7 +2331,7 @@ function d_code(dist) {
* Output a short LSB first on the stream. * Output a short LSB first on the stream.
* IN assertion: there is enough room in pendingBuf. * IN assertion: there is enough room in pendingBuf.
*/ */
function put_short (s, w) { function put_short(s, w) {
// put_byte(s, (uch)((w) & 0xff)); // put_byte(s, (uch)((w) & 0xff));
// put_byte(s, (uch)((ush)(w) >> 8)); // put_byte(s, (uch)((ush)(w) >> 8));
s.pending_buf[s.pending++] = (w) & 0xff; s.pending_buf[s.pending++] = (w) & 0xff;
@ -2354,7 +2357,7 @@ function send_bits(s, value, length) {
function send_code(s, c, tree) { function send_code(s, c, tree) {
send_bits(s, tree[c*2]/*.Code*/, tree[c*2 + 1]/*.Len*/); send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);
} }
@ -2426,16 +2429,16 @@ function gen_bitlen(s, desc)
/* In a first pass, compute the optimal bit lengths (which may /* In a first pass, compute the optimal bit lengths (which may
* overflow in the case of the bit length tree). * overflow in the case of the bit length tree).
*/ */
tree[s.heap[s.heap_max]*2 + 1]/*.Len*/ = 0; /* root of the heap */ tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */
for (h = s.heap_max+1; h < HEAP_SIZE; h++) { for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {
n = s.heap[h]; n = s.heap[h];
bits = tree[tree[n*2 +1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1; bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;
if (bits > max_length) { if (bits > max_length) {
bits = max_length; bits = max_length;
overflow++; overflow++;
} }
tree[n*2 + 1]/*.Len*/ = bits; tree[n * 2 + 1]/*.Len*/ = bits;
/* We overwrite tree[n].Dad which is no longer needed */ /* We overwrite tree[n].Dad which is no longer needed */
if (n > max_code) { continue; } /* not a leaf node */ if (n > max_code) { continue; } /* not a leaf node */
@ -2443,12 +2446,12 @@ function gen_bitlen(s, desc)
s.bl_count[bits]++; s.bl_count[bits]++;
xbits = 0; xbits = 0;
if (n >= base) { if (n >= base) {
xbits = extra[n-base]; xbits = extra[n - base];
} }
f = tree[n * 2]/*.Freq*/; f = tree[n * 2]/*.Freq*/;
s.opt_len += f * (bits + xbits); s.opt_len += f * (bits + xbits);
if (has_stree) { if (has_stree) {
s.static_len += f * (stree[n*2 + 1]/*.Len*/ + xbits); s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);
} }
} }
if (overflow === 0) { return; } if (overflow === 0) { return; }
@ -2458,10 +2461,10 @@ function gen_bitlen(s, desc)
/* Find the first bit length which could increase: */ /* Find the first bit length which could increase: */
do { do {
bits = max_length-1; bits = max_length - 1;
while (s.bl_count[bits] === 0) { bits--; } while (s.bl_count[bits] === 0) { bits--; }
s.bl_count[bits]--; /* move one leaf down the tree */ s.bl_count[bits]--; /* move one leaf down the tree */
s.bl_count[bits+1] += 2; /* move one overflow item as its brother */ s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */
s.bl_count[max_length]--; s.bl_count[max_length]--;
/* The brother of the overflow item also moves one step up, /* The brother of the overflow item also moves one step up,
* but this does not affect bl_count[max_length] * but this does not affect bl_count[max_length]
@ -2479,10 +2482,10 @@ function gen_bitlen(s, desc)
while (n !== 0) { while (n !== 0) {
m = s.heap[--h]; m = s.heap[--h];
if (m > max_code) { continue; } if (m > max_code) { continue; }
if (tree[m*2 + 1]/*.Len*/ !== bits) { if (tree[m * 2 + 1]/*.Len*/ !== bits) {
// Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); // Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
s.opt_len += (bits - tree[m*2 + 1]/*.Len*/)*tree[m*2]/*.Freq*/; s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;
tree[m*2 + 1]/*.Len*/ = bits; tree[m * 2 + 1]/*.Len*/ = bits;
} }
n--; n--;
} }
@ -2503,7 +2506,7 @@ function gen_codes(tree, max_code, bl_count)
// int max_code; /* largest code with non zero frequency */ // int max_code; /* largest code with non zero frequency */
// ushf *bl_count; /* number of codes at each bit length */ // ushf *bl_count; /* number of codes at each bit length */
{ {
var next_code = new Array(MAX_BITS+1); /* next code value for each bit length */ var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */
var code = 0; /* running code value */ var code = 0; /* running code value */
var bits; /* bit index */ var bits; /* bit index */
var n; /* code index */ var n; /* code index */
@ -2512,7 +2515,7 @@ function gen_codes(tree, max_code, bl_count)
* without bit reversal. * without bit reversal.
*/ */
for (bits = 1; bits <= MAX_BITS; bits++) { for (bits = 1; bits <= MAX_BITS; bits++) {
next_code[bits] = code = (code + bl_count[bits-1]) << 1; next_code[bits] = code = (code + bl_count[bits - 1]) << 1;
} }
/* Check that the bit counts in bl_count are consistent. The last code /* Check that the bit counts in bl_count are consistent. The last code
* must be all ones. * must be all ones.
@ -2522,10 +2525,10 @@ function gen_codes(tree, max_code, bl_count)
//Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); //Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
for (n = 0; n <= max_code; n++) { for (n = 0; n <= max_code; n++) {
var len = tree[n*2 + 1]/*.Len*/; var len = tree[n * 2 + 1]/*.Len*/;
if (len === 0) { continue; } if (len === 0) { continue; }
/* Now reverse the bits */ /* Now reverse the bits */
tree[n*2]/*.Code*/ = bi_reverse(next_code[len]++, len); tree[n * 2]/*.Code*/ = bi_reverse(next_code[len]++, len);
//Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", //Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
// n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1)); // n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
@ -2542,7 +2545,7 @@ function tr_static_init() {
var length; /* length value */ var length; /* length value */
var code; /* code value */ var code; /* code value */
var dist; /* distance index */ var dist; /* distance index */
var bl_count = new Array(MAX_BITS+1); var bl_count = new Array(MAX_BITS + 1);
/* number of codes at each bit length for an optimal tree */ /* number of codes at each bit length for an optimal tree */
// do check in _tr_init() // do check in _tr_init()
@ -2559,9 +2562,9 @@ function tr_static_init() {
/* Initialize the mapping length (0..255) -> length code (0..28) */ /* Initialize the mapping length (0..255) -> length code (0..28) */
length = 0; length = 0;
for (code = 0; code < LENGTH_CODES-1; code++) { for (code = 0; code < LENGTH_CODES - 1; code++) {
base_length[code] = length; base_length[code] = length;
for (n = 0; n < (1<<extra_lbits[code]); n++) { for (n = 0; n < (1 << extra_lbits[code]); n++) {
_length_code[length++] = code; _length_code[length++] = code;
} }
} }
@ -2570,13 +2573,13 @@ function tr_static_init() {
* in two different ways: code 284 + 5 bits or code 285, so we * in two different ways: code 284 + 5 bits or code 285, so we
* overwrite length_code[255] to use the best encoding: * overwrite length_code[255] to use the best encoding:
*/ */
_length_code[length-1] = code; _length_code[length - 1] = code;
/* Initialize the mapping dist (0..32K) -> dist code (0..29) */ /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
dist = 0; dist = 0;
for (code = 0 ; code < 16; code++) { for (code = 0; code < 16; code++) {
base_dist[code] = dist; base_dist[code] = dist;
for (n = 0; n < (1<<extra_dbits[code]); n++) { for (n = 0; n < (1 << extra_dbits[code]); n++) {
_dist_code[dist++] = code; _dist_code[dist++] = code;
} }
} }
@ -2584,7 +2587,7 @@ function tr_static_init() {
dist >>= 7; /* from now on, all distances are divided by 128 */ dist >>= 7; /* from now on, all distances are divided by 128 */
for (; code < D_CODES; code++) { for (; code < D_CODES; code++) {
base_dist[code] = dist << 7; base_dist[code] = dist << 7;
for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {
_dist_code[256 + dist++] = code; _dist_code[256 + dist++] = code;
} }
} }
@ -2597,22 +2600,22 @@ function tr_static_init() {
n = 0; n = 0;
while (n <= 143) { while (n <= 143) {
static_ltree[n*2 + 1]/*.Len*/ = 8; static_ltree[n * 2 + 1]/*.Len*/ = 8;
n++; n++;
bl_count[8]++; bl_count[8]++;
} }
while (n <= 255) { while (n <= 255) {
static_ltree[n*2 + 1]/*.Len*/ = 9; static_ltree[n * 2 + 1]/*.Len*/ = 9;
n++; n++;
bl_count[9]++; bl_count[9]++;
} }
while (n <= 279) { while (n <= 279) {
static_ltree[n*2 + 1]/*.Len*/ = 7; static_ltree[n * 2 + 1]/*.Len*/ = 7;
n++; n++;
bl_count[7]++; bl_count[7]++;
} }
while (n <= 287) { while (n <= 287) {
static_ltree[n*2 + 1]/*.Len*/ = 8; static_ltree[n * 2 + 1]/*.Len*/ = 8;
n++; n++;
bl_count[8]++; bl_count[8]++;
} }
@ -2620,18 +2623,18 @@ function tr_static_init() {
* tree construction to get a canonical Huffman tree (longest code * tree construction to get a canonical Huffman tree (longest code
* all ones) * all ones)
*/ */
gen_codes(static_ltree, L_CODES+1, bl_count); gen_codes(static_ltree, L_CODES + 1, bl_count);
/* The static distance tree is trivial: */ /* The static distance tree is trivial: */
for (n = 0; n < D_CODES; n++) { for (n = 0; n < D_CODES; n++) {
static_dtree[n*2 + 1]/*.Len*/ = 5; static_dtree[n * 2 + 1]/*.Len*/ = 5;
static_dtree[n*2]/*.Code*/ = bi_reverse(n, 5); static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);
} }
// Now data ready and we can init static trees // Now data ready and we can init static trees
static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS); static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);
static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS); static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);
static_bl_desc =new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);
//static_init_done = true; //static_init_done = true;
} }
@ -2644,11 +2647,11 @@ function init_block(s) {
var n; /* iterates over tree elements */ var n; /* iterates over tree elements */
/* Initialize the trees. */ /* Initialize the trees. */
for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n*2]/*.Freq*/ = 0; } for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }
for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n*2]/*.Freq*/ = 0; } for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }
for (n = 0; n < BL_CODES; n++) { s.bl_tree[n*2]/*.Freq*/ = 0; } for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }
s.dyn_ltree[END_BLOCK*2]/*.Freq*/ = 1; s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;
s.opt_len = s.static_len = 0; s.opt_len = s.static_len = 0;
s.last_lit = s.matches = 0; s.last_lit = s.matches = 0;
} }
@ -2697,8 +2700,8 @@ function copy_block(s, buf, len, header)
* the subtrees have equal frequency. This minimizes the worst case length. * the subtrees have equal frequency. This minimizes the worst case length.
*/ */
function smaller(tree, n, m, depth) { function smaller(tree, n, m, depth) {
var _n2 = n*2; var _n2 = n * 2;
var _m2 = m*2; var _m2 = m * 2;
return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ || return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||
(tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m])); (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));
} }
@ -2719,7 +2722,7 @@ function pqdownheap(s, tree, k)
while (j <= s.heap_len) { while (j <= s.heap_len) {
/* Set j to the smallest of the two sons: */ /* Set j to the smallest of the two sons: */
if (j < s.heap_len && if (j < s.heap_len &&
smaller(tree, s.heap[j+1], s.heap[j], s.depth)) { smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {
j++; j++;
} }
/* Exit if v is smaller than both sons */ /* Exit if v is smaller than both sons */
@ -2755,7 +2758,7 @@ function compress_block(s, ltree, dtree)
if (s.last_lit !== 0) { if (s.last_lit !== 0) {
do { do {
dist = (s.pending_buf[s.d_buf + lx*2] << 8) | (s.pending_buf[s.d_buf + lx*2 + 1]); dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);
lc = s.pending_buf[s.l_buf + lx]; lc = s.pending_buf[s.l_buf + lx];
lx++; lx++;
@ -2765,7 +2768,7 @@ function compress_block(s, ltree, dtree)
} else { } else {
/* Here, lc is the match length - MIN_MATCH */ /* Here, lc is the match length - MIN_MATCH */
code = _length_code[lc]; code = _length_code[lc];
send_code(s, code+LITERALS+1, ltree); /* send the length code */ send_code(s, code + LITERALS + 1, ltree); /* send the length code */
extra = extra_lbits[code]; extra = extra_lbits[code];
if (extra !== 0) { if (extra !== 0) {
lc -= base_length[code]; lc -= base_length[code];
@ -2827,7 +2830,7 @@ function build_tree(s, desc)
s.depth[n] = 0; s.depth[n] = 0;
} else { } else {
tree[n*2 + 1]/*.Len*/ = 0; tree[n * 2 + 1]/*.Len*/ = 0;
} }
} }
@ -2843,7 +2846,7 @@ function build_tree(s, desc)
s.opt_len--; s.opt_len--;
if (has_stree) { if (has_stree) {
s.static_len -= stree[node*2 + 1]/*.Len*/; s.static_len -= stree[node * 2 + 1]/*.Len*/;
} }
/* node is 0 or 1 so it does not have extra bits */ /* node is 0 or 1 so it does not have extra bits */
} }
@ -2874,7 +2877,7 @@ function build_tree(s, desc)
/* Create a new node father of n and m */ /* Create a new node father of n and m */
tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/; tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;
s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1; s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;
tree[n*2 + 1]/*.Dad*/ = tree[m*2 + 1]/*.Dad*/ = node; tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;
/* and insert the new node in the heap */ /* and insert the new node in the heap */
s.heap[1/*SMALLEST*/] = node++; s.heap[1/*SMALLEST*/] = node++;
@ -2907,7 +2910,7 @@ function scan_tree(s, tree, max_code)
var prevlen = -1; /* last emitted length */ var prevlen = -1; /* last emitted length */
var curlen; /* length of current code */ var curlen; /* length of current code */
var nextlen = tree[0*2 + 1]/*.Len*/; /* length of next code */ var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */
var count = 0; /* repeat count of the current code */ var count = 0; /* repeat count of the current code */
var max_count = 7; /* max repeat count */ var max_count = 7; /* max repeat count */
@ -2917,11 +2920,11 @@ function scan_tree(s, tree, max_code)
max_count = 138; max_count = 138;
min_count = 3; min_count = 3;
} }
tree[(max_code+1)*2 + 1]/*.Len*/ = 0xffff; /* guard */ tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */
for (n = 0; n <= max_code; n++) { for (n = 0; n <= max_code; n++) {
curlen = nextlen; curlen = nextlen;
nextlen = tree[(n+1)*2 + 1]/*.Len*/; nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;
if (++count < max_count && curlen === nextlen) { if (++count < max_count && curlen === nextlen) {
continue; continue;
@ -2932,13 +2935,13 @@ function scan_tree(s, tree, max_code)
} else if (curlen !== 0) { } else if (curlen !== 0) {
if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; } if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }
s.bl_tree[REP_3_6*2]/*.Freq*/++; s.bl_tree[REP_3_6 * 2]/*.Freq*/++;
} else if (count <= 10) { } else if (count <= 10) {
s.bl_tree[REPZ_3_10*2]/*.Freq*/++; s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;
} else { } else {
s.bl_tree[REPZ_11_138*2]/*.Freq*/++; s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;
} }
count = 0; count = 0;
@ -2973,7 +2976,7 @@ function send_tree(s, tree, max_code)
var prevlen = -1; /* last emitted length */ var prevlen = -1; /* last emitted length */
var curlen; /* length of current code */ var curlen; /* length of current code */
var nextlen = tree[0*2 + 1]/*.Len*/; /* length of next code */ var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */
var count = 0; /* repeat count of the current code */ var count = 0; /* repeat count of the current code */
var max_count = 7; /* max repeat count */ var max_count = 7; /* max repeat count */
@ -2987,7 +2990,7 @@ function send_tree(s, tree, max_code)
for (n = 0; n <= max_code; n++) { for (n = 0; n <= max_code; n++) {
curlen = nextlen; curlen = nextlen;
nextlen = tree[(n+1)*2 + 1]/*.Len*/; nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;
if (++count < max_count && curlen === nextlen) { if (++count < max_count && curlen === nextlen) {
continue; continue;
@ -3002,15 +3005,15 @@ function send_tree(s, tree, max_code)
} }
//Assert(count >= 3 && count <= 6, " 3_6?"); //Assert(count >= 3 && count <= 6, " 3_6?");
send_code(s, REP_3_6, s.bl_tree); send_code(s, REP_3_6, s.bl_tree);
send_bits(s, count-3, 2); send_bits(s, count - 3, 2);
} else if (count <= 10) { } else if (count <= 10) {
send_code(s, REPZ_3_10, s.bl_tree); send_code(s, REPZ_3_10, s.bl_tree);
send_bits(s, count-3, 3); send_bits(s, count - 3, 3);
} else { } else {
send_code(s, REPZ_11_138, s.bl_tree); send_code(s, REPZ_11_138, s.bl_tree);
send_bits(s, count-11, 7); send_bits(s, count - 11, 7);
} }
count = 0; count = 0;
@ -3052,13 +3055,13 @@ function build_bl_tree(s) {
* requires that at least 4 bit length codes be sent. (appnote.txt says * requires that at least 4 bit length codes be sent. (appnote.txt says
* 3 but the actual value used is 4.) * 3 but the actual value used is 4.)
*/ */
for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {
if (s.bl_tree[bl_order[max_blindex]*2 + 1]/*.Len*/ !== 0) { if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {
break; break;
} }
} }
/* Update opt_len to include the bit length tree and counts */ /* Update opt_len to include the bit length tree and counts */
s.opt_len += 3*(max_blindex+1) + 5+5+4; s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;
//Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", //Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
// s->opt_len, s->static_len)); // s->opt_len, s->static_len));
@ -3081,19 +3084,19 @@ function send_all_trees(s, lcodes, dcodes, blcodes)
//Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
// "too many codes"); // "too many codes");
//Tracev((stderr, "\nbl counts: ")); //Tracev((stderr, "\nbl counts: "));
send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */
send_bits(s, dcodes-1, 5); send_bits(s, dcodes - 1, 5);
send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */
for (rank = 0; rank < blcodes; rank++) { for (rank = 0; rank < blcodes; rank++) {
//Tracev((stderr, "\nbl code %2d ", bl_order[rank])); //Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
send_bits(s, s.bl_tree[bl_order[rank]*2 + 1]/*.Len*/, 3); send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);
} }
//Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); //Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
send_tree(s, s.dyn_ltree, lcodes-1); /* literal tree */ send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */
//Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); //Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
send_tree(s, s.dyn_dtree, dcodes-1); /* distance tree */ send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */
//Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); //Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
} }
@ -3121,7 +3124,7 @@ function detect_data_type(s) {
/* Check for non-textual ("black-listed") bytes. */ /* Check for non-textual ("black-listed") bytes. */
for (n = 0; n <= 31; n++, black_mask >>>= 1) { for (n = 0; n <= 31; n++, black_mask >>>= 1) {
if ((black_mask & 1) && (s.dyn_ltree[n*2]/*.Freq*/ !== 0)) { if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {
return Z_BINARY; return Z_BINARY;
} }
} }
@ -3178,7 +3181,7 @@ function _tr_stored_block(s, buf, stored_len, last)
//ulg stored_len; /* length of input block */ //ulg stored_len; /* length of input block */
//int last; /* one if this is the last block for a file */ //int last; /* one if this is the last block for a file */
{ {
send_bits(s, (STORED_BLOCK<<1)+(last ? 1 : 0), 3); /* send block type */ send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */
copy_block(s, buf, stored_len, true); /* with header */ copy_block(s, buf, stored_len, true); /* with header */
} }
@ -3188,7 +3191,7 @@ function _tr_stored_block(s, buf, stored_len, last)
* This takes 10 bits, of which 7 may remain in the bit buffer. * This takes 10 bits, of which 7 may remain in the bit buffer.
*/ */
function _tr_align(s) { function _tr_align(s) {
send_bits(s, STATIC_TREES<<1, 3); send_bits(s, STATIC_TREES << 1, 3);
send_code(s, END_BLOCK, static_ltree); send_code(s, END_BLOCK, static_ltree);
bi_flush(s); bi_flush(s);
} }
@ -3233,8 +3236,8 @@ function _tr_flush_block(s, buf, stored_len, last)
max_blindex = build_bl_tree(s); max_blindex = build_bl_tree(s);
/* Determine the best encoding. Compute the block lengths in bytes. */ /* Determine the best encoding. Compute the block lengths in bytes. */
opt_lenb = (s.opt_len+3+7) >>> 3; opt_lenb = (s.opt_len + 3 + 7) >>> 3;
static_lenb = (s.static_len+3+7) >>> 3; static_lenb = (s.static_len + 3 + 7) >>> 3;
// Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", // Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
// opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
@ -3247,7 +3250,7 @@ function _tr_flush_block(s, buf, stored_len, last)
opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
} }
if ((stored_len+4 <= opt_lenb) && (buf !== -1)) { if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {
/* 4: two words for the lengths */ /* 4: two words for the lengths */
/* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
@ -3260,12 +3263,12 @@ function _tr_flush_block(s, buf, stored_len, last)
} else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) { } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {
send_bits(s, (STATIC_TREES<<1) + (last ? 1 : 0), 3); send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);
compress_block(s, static_ltree, static_dtree); compress_block(s, static_ltree, static_dtree);
} else { } else {
send_bits(s, (DYN_TREES<<1) + (last ? 1 : 0), 3); send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);
send_all_trees(s, s.l_desc.max_code+1, s.d_desc.max_code+1, max_blindex+1); send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);
compress_block(s, s.dyn_ltree, s.dyn_dtree); compress_block(s, s.dyn_ltree, s.dyn_dtree);
} }
// Assert (s->compressed_len == s->bits_sent, "bad compressed size"); // Assert (s->compressed_len == s->bits_sent, "bad compressed size");
@ -3300,7 +3303,7 @@ function _tr_tally(s, dist, lc)
if (dist === 0) { if (dist === 0) {
/* lc is the unmatched char */ /* lc is the unmatched char */
s.dyn_ltree[lc*2]/*.Freq*/++; s.dyn_ltree[lc * 2]/*.Freq*/++;
} else { } else {
s.matches++; s.matches++;
/* Here, lc is the match length - MIN_MATCH */ /* Here, lc is the match length - MIN_MATCH */
@ -3309,7 +3312,7 @@ function _tr_tally(s, dist, lc)
// (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
// (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); // (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
s.dyn_ltree[(_length_code[lc]+LITERALS+1) * 2]/*.Freq*/++; s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;
s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++; s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;
} }
@ -3336,7 +3339,7 @@ function _tr_tally(s, dist, lc)
// } // }
//#endif //#endif
return (s.last_lit === s.lit_bufsize-1); return (s.last_lit === s.lit_bufsize - 1);
/* We avoid equality with lit_bufsize because of wraparound at 64K /* We avoid equality with lit_bufsize because of wraparound at 64K
* on 16 bit machines and because stored blocks are restricted to * on 16 bit machines and because stored blocks are restricted to
* 64K-1 bytes. * 64K-1 bytes.
@ -3384,11 +3387,11 @@ module.exports = ZStream;
'use strict'; 'use strict';
var zlib_deflate = require('./zlib/deflate.js'); var zlib_deflate = require('./zlib/deflate');
var utils = require('./utils/common'); var utils = require('./utils/common');
var strings = require('./utils/strings'); var strings = require('./utils/strings');
var msg = require('./zlib/messages'); var msg = require('./zlib/messages');
var zstream = require('./zlib/zstream'); var ZStream = require('./zlib/zstream');
var toString = Object.prototype.toString; var toString = Object.prototype.toString;
@ -3499,7 +3502,8 @@ var Z_DEFLATED = 8;
* console.log(deflate.result); * console.log(deflate.result);
* ``` * ```
**/ **/
var Deflate = function(options) { function Deflate(options) {
if (!(this instanceof Deflate)) return new Deflate(options);
this.options = utils.assign({ this.options = utils.assign({
level: Z_DEFAULT_COMPRESSION, level: Z_DEFAULT_COMPRESSION,
@ -3526,7 +3530,7 @@ var Deflate = function(options) {
this.ended = false; // used to avoid multiple onEnd() calls this.ended = false; // used to avoid multiple onEnd() calls
this.chunks = []; // chunks of compressed data this.chunks = []; // chunks of compressed data
this.strm = new zstream(); this.strm = new ZStream();
this.strm.avail_out = 0; this.strm.avail_out = 0;
var status = zlib_deflate.deflateInit2( var status = zlib_deflate.deflateInit2(
@ -3545,7 +3549,7 @@ var Deflate = function(options) {
if (opt.header) { if (opt.header) {
zlib_deflate.deflateSetHeader(this.strm, opt.header); zlib_deflate.deflateSetHeader(this.strm, opt.header);
} }
}; }
/** /**
* Deflate#push(data[, mode]) -> Boolean * Deflate#push(data[, mode]) -> Boolean
@ -3576,7 +3580,7 @@ var Deflate = function(options) {
* push(chunk, true); // push last chunk * push(chunk, true); // push last chunk
* ``` * ```
**/ **/
Deflate.prototype.push = function(data, mode) { Deflate.prototype.push = function (data, mode) {
var strm = this.strm; var strm = this.strm;
var chunkSize = this.options.chunkSize; var chunkSize = this.options.chunkSize;
var status, _mode; var status, _mode;
@ -3648,7 +3652,7 @@ Deflate.prototype.push = function(data, mode) {
* By default, stores data blocks in `chunks[]` property and glue * By default, stores data blocks in `chunks[]` property and glue
* those in `onEnd`. Override this handler, if you need another behaviour. * those in `onEnd`. Override this handler, if you need another behaviour.
**/ **/
Deflate.prototype.onData = function(chunk) { Deflate.prototype.onData = function (chunk) {
this.chunks.push(chunk); this.chunks.push(chunk);
}; };
@ -3663,7 +3667,7 @@ Deflate.prototype.onData = function(chunk) {
* or if an error happened. By default - join collected chunks, * or if an error happened. By default - join collected chunks,
* free memory and fill `results` / `err` properties. * free memory and fill `results` / `err` properties.
**/ **/
Deflate.prototype.onEnd = function(status) { Deflate.prototype.onEnd = function (status) {
// On success - join // On success - join
if (status === Z_OK) { if (status === Z_OK) {
if (this.options.to === 'string') { if (this.options.to === 'string') {
@ -3758,5 +3762,5 @@ exports.deflate = deflate;
exports.deflateRaw = deflateRaw; exports.deflateRaw = deflateRaw;
exports.gzip = gzip; exports.gzip = gzip;
},{"./utils/common":1,"./utils/strings":2,"./zlib/deflate.js":5,"./zlib/messages":6,"./zlib/zstream":8}]},{},[])("/lib/deflate.js") },{"./utils/common":1,"./utils/strings":2,"./zlib/deflate":5,"./zlib/messages":6,"./zlib/zstream":8}]},{},[])("/lib/deflate.js")
}); });

File diff suppressed because one or more lines are too long

154
dist/pako_inflate.js vendored
View file

@ -1,4 +1,4 @@
/* pako 0.2.8 nodeca/pako */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.pako = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ /* pako 1.0.0 nodeca/pako */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.pako = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict'; 'use strict';
@ -40,28 +40,28 @@ exports.shrinkBuf = function (buf, size) {
var fnTyped = { var fnTyped = {
arraySet: function (dest, src, src_offs, len, dest_offs) { arraySet: function (dest, src, src_offs, len, dest_offs) {
if (src.subarray && dest.subarray) { if (src.subarray && dest.subarray) {
dest.set(src.subarray(src_offs, src_offs+len), dest_offs); dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
return; return;
} }
// Fallback to ordinary array // Fallback to ordinary array
for (var i=0; i<len; i++) { for (var i = 0; i < len; i++) {
dest[dest_offs + i] = src[src_offs + i]; dest[dest_offs + i] = src[src_offs + i];
} }
}, },
// Join array of chunks to single array. // Join array of chunks to single array.
flattenChunks: function(chunks) { flattenChunks: function (chunks) {
var i, l, len, pos, chunk, result; var i, l, len, pos, chunk, result;
// calculate data length // calculate data length
len = 0; len = 0;
for (i=0, l=chunks.length; i<l; i++) { for (i = 0, l = chunks.length; i < l; i++) {
len += chunks[i].length; len += chunks[i].length;
} }
// join chunks // join chunks
result = new Uint8Array(len); result = new Uint8Array(len);
pos = 0; pos = 0;
for (i=0, l=chunks.length; i<l; i++) { for (i = 0, l = chunks.length; i < l; i++) {
chunk = chunks[i]; chunk = chunks[i];
result.set(chunk, pos); result.set(chunk, pos);
pos += chunk.length; pos += chunk.length;
@ -73,12 +73,12 @@ var fnTyped = {
var fnUntyped = { var fnUntyped = {
arraySet: function (dest, src, src_offs, len, dest_offs) { arraySet: function (dest, src, src_offs, len, dest_offs) {
for (var i=0; i<len; i++) { for (var i = 0; i < len; i++) {
dest[dest_offs + i] = src[src_offs + i]; dest[dest_offs + i] = src[src_offs + i];
} }
}, },
// Join array of chunks to single array. // Join array of chunks to single array.
flattenChunks: function(chunks) { flattenChunks: function (chunks) {
return [].concat.apply([], chunks); return [].concat.apply([], chunks);
} }
}; };
@ -118,18 +118,18 @@ var utils = require('./common');
var STR_APPLY_OK = true; var STR_APPLY_OK = true;
var STR_APPLY_UIA_OK = true; var STR_APPLY_UIA_OK = true;
try { String.fromCharCode.apply(null, [0]); } catch(__) { STR_APPLY_OK = false; } try { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }
try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch(__) { STR_APPLY_UIA_OK = false; } try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }
// Table with utf8 lengths (calculated by first byte of sequence) // Table with utf8 lengths (calculated by first byte of sequence)
// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS, // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
// because max possible codepoint is 0x10ffff // because max possible codepoint is 0x10ffff
var _utf8len = new utils.Buf8(256); var _utf8len = new utils.Buf8(256);
for (var q=0; q<256; q++) { for (var q = 0; q < 256; q++) {
_utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1); _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);
} }
_utf8len[254]=_utf8len[254]=1; // Invalid sequence start _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start
// convert string to array (typed, when possible) // convert string to array (typed, when possible)
@ -139,8 +139,8 @@ exports.string2buf = function (str) {
// count binary size // count binary size
for (m_pos = 0; m_pos < str_len; m_pos++) { for (m_pos = 0; m_pos < str_len; m_pos++) {
c = str.charCodeAt(m_pos); c = str.charCodeAt(m_pos);
if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) { if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
c2 = str.charCodeAt(m_pos+1); c2 = str.charCodeAt(m_pos + 1);
if ((c2 & 0xfc00) === 0xdc00) { if ((c2 & 0xfc00) === 0xdc00) {
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
m_pos++; m_pos++;
@ -153,10 +153,10 @@ exports.string2buf = function (str) {
buf = new utils.Buf8(buf_len); buf = new utils.Buf8(buf_len);
// convert // convert
for (i=0, m_pos = 0; i < buf_len; m_pos++) { for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
c = str.charCodeAt(m_pos); c = str.charCodeAt(m_pos);
if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) { if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
c2 = str.charCodeAt(m_pos+1); c2 = str.charCodeAt(m_pos + 1);
if ((c2 & 0xfc00) === 0xdc00) { if ((c2 & 0xfc00) === 0xdc00) {
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
m_pos++; m_pos++;
@ -196,7 +196,7 @@ function buf2binstring(buf, len) {
} }
var result = ''; var result = '';
for (var i=0; i < len; i++) { for (var i = 0; i < len; i++) {
result += String.fromCharCode(buf[i]); result += String.fromCharCode(buf[i]);
} }
return result; return result;
@ -204,15 +204,15 @@ function buf2binstring(buf, len) {
// Convert byte array to binary string // Convert byte array to binary string
exports.buf2binstring = function(buf) { exports.buf2binstring = function (buf) {
return buf2binstring(buf, buf.length); return buf2binstring(buf, buf.length);
}; };
// Convert binary string (typed, when possible) // Convert binary string (typed, when possible)
exports.binstring2buf = function(str) { exports.binstring2buf = function (str) {
var buf = new utils.Buf8(str.length); var buf = new utils.Buf8(str.length);
for (var i=0, len=buf.length; i < len; i++) { for (var i = 0, len = buf.length; i < len; i++) {
buf[i] = str.charCodeAt(i); buf[i] = str.charCodeAt(i);
} }
return buf; return buf;
@ -227,16 +227,16 @@ exports.buf2string = function (buf, max) {
// Reserve max possible length (2 words per char) // Reserve max possible length (2 words per char)
// NB: by unknown reasons, Array is significantly faster for // NB: by unknown reasons, Array is significantly faster for
// String.fromCharCode.apply than Uint16Array. // String.fromCharCode.apply than Uint16Array.
var utf16buf = new Array(len*2); var utf16buf = new Array(len * 2);
for (out=0, i=0; i<len;) { for (out = 0, i = 0; i < len;) {
c = buf[i++]; c = buf[i++];
// quick process ascii // quick process ascii
if (c < 0x80) { utf16buf[out++] = c; continue; } if (c < 0x80) { utf16buf[out++] = c; continue; }
c_len = _utf8len[c]; c_len = _utf8len[c];
// skip 5 & 6 byte codes // skip 5 & 6 byte codes
if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len-1; continue; } if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }
// apply mask on first byte // apply mask on first byte
c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;
@ -268,14 +268,14 @@ exports.buf2string = function (buf, max) {
// //
// buf[] - utf8 bytes array // buf[] - utf8 bytes array
// max - length limit (mandatory); // max - length limit (mandatory);
exports.utf8border = function(buf, max) { exports.utf8border = function (buf, max) {
var pos; var pos;
max = max || buf.length; max = max || buf.length;
if (max > buf.length) { max = buf.length; } if (max > buf.length) { max = buf.length; }
// go back from last position, until start of sequence found // go back from last position, until start of sequence found
pos = max-1; pos = max - 1;
while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; } while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }
// Fuckup - very small and broken sequence, // Fuckup - very small and broken sequence,
@ -324,6 +324,9 @@ function adler32(adler, buf, len, pos) {
module.exports = adler32; module.exports = adler32;
},{}],4:[function(require,module,exports){ },{}],4:[function(require,module,exports){
'use strict';
module.exports = { module.exports = {
/* Allowed flush values; see deflate() and inflate() below for details */ /* Allowed flush values; see deflate() and inflate() below for details */
@ -384,10 +387,10 @@ module.exports = {
function makeTable() { function makeTable() {
var c, table = []; var c, table = [];
for (var n =0; n < 256; n++) { for (var n = 0; n < 256; n++) {
c = n; c = n;
for (var k =0; k < 8; k++) { for (var k = 0; k < 8; k++) {
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)); c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
} }
table[n] = c; table[n] = c;
} }
@ -403,7 +406,7 @@ function crc32(crc, buf, len, pos) {
var t = crcTable, var t = crcTable,
end = pos + len; end = pos + len;
crc = crc ^ (-1); crc ^= -1;
for (var i = pos; i < end; i++) { for (var i = pos; i < end; i++) {
crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF]; crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
@ -789,10 +792,10 @@ module.exports = function inflate_fast(strm, start) {
'use strict'; 'use strict';
var utils = require('../utils/common'); var utils = require('../utils/common');
var adler32 = require('./adler32'); var adler32 = require('./adler32');
var crc32 = require('./crc32'); var crc32 = require('./crc32');
var inflate_fast = require('./inffast'); var inflate_fast = require('./inffast');
var inflate_table = require('./inftrees'); var inflate_table = require('./inftrees');
var CODES = 0; var CODES = 0;
@ -880,7 +883,7 @@ var MAX_WBITS = 15;
var DEF_WBITS = MAX_WBITS; var DEF_WBITS = MAX_WBITS;
function ZSWAP32(q) { function zswap32(q) {
return (((q >>> 24) & 0xff) + return (((q >>> 24) & 0xff) +
((q >>> 8) & 0xff00) + ((q >>> 8) & 0xff00) +
((q & 0xff00) << 8) + ((q & 0xff00) << 8) +
@ -1073,13 +1076,13 @@ function fixedtables(state) {
while (sym < 280) { state.lens[sym++] = 7; } while (sym < 280) { state.lens[sym++] = 7; }
while (sym < 288) { state.lens[sym++] = 8; } while (sym < 288) { state.lens[sym++] = 8; }
inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, {bits: 9}); inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });
/* distance table */ /* distance table */
sym = 0; sym = 0;
while (sym < 32) { state.lens[sym++] = 5; } while (sym < 32) { state.lens[sym++] = 5; }
inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, {bits: 5}); inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });
/* do this just once */ /* do this just once */
virgin = false; virgin = false;
@ -1121,7 +1124,7 @@ function updatewindow(strm, src, end, copy) {
/* copy state->wsize or less output bytes into the circular window */ /* copy state->wsize or less output bytes into the circular window */
if (copy >= state.wsize) { if (copy >= state.wsize) {
utils.arraySet(state.window,src, end - state.wsize, state.wsize, 0); utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
state.wnext = 0; state.wnext = 0;
state.whave = state.wsize; state.whave = state.wsize;
} }
@ -1131,11 +1134,11 @@ function updatewindow(strm, src, end, copy) {
dist = copy; dist = copy;
} }
//zmemcpy(state->window + state->wnext, end - copy, dist); //zmemcpy(state->window + state->wnext, end - copy, dist);
utils.arraySet(state.window,src, end - copy, dist, state.wnext); utils.arraySet(state.window, src, end - copy, dist, state.wnext);
copy -= dist; copy -= dist;
if (copy) { if (copy) {
//zmemcpy(state->window, end - copy, copy); //zmemcpy(state->window, end - copy, copy);
utils.arraySet(state.window,src, end - copy, copy, 0); utils.arraySet(state.window, src, end - copy, copy, 0);
state.wnext = copy; state.wnext = copy;
state.whave = state.wsize; state.whave = state.wsize;
} }
@ -1172,7 +1175,7 @@ function inflate(strm, flush) {
var n; // temporary var for NEED_BITS var n; // temporary var for NEED_BITS
var order = /* permutation of code lengths */ var order = /* permutation of code lengths */
[16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];
if (!strm || !strm.state || !strm.output || if (!strm || !strm.state || !strm.output ||
@ -1499,7 +1502,7 @@ function inflate(strm, flush) {
state.head.hcrc = ((state.flags >> 9) & 1); state.head.hcrc = ((state.flags >> 9) & 1);
state.head.done = true; state.head.done = true;
} }
strm.adler = state.check = 0 /*crc32(0L, Z_NULL, 0)*/; strm.adler = state.check = 0;
state.mode = TYPE; state.mode = TYPE;
break; break;
case DICTID: case DICTID:
@ -1511,7 +1514,7 @@ function inflate(strm, flush) {
bits += 8; bits += 8;
} }
//===// //===//
strm.adler = state.check = ZSWAP32(hold); strm.adler = state.check = zswap32(hold);
//=== INITBITS(); //=== INITBITS();
hold = 0; hold = 0;
bits = 0; bits = 0;
@ -1703,7 +1706,7 @@ function inflate(strm, flush) {
state.lencode = state.lendyn; state.lencode = state.lendyn;
state.lenbits = 7; state.lenbits = 7;
opts = {bits: state.lenbits}; opts = { bits: state.lenbits };
ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts); ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
state.lenbits = opts.bits; state.lenbits = opts.bits;
@ -1834,7 +1837,7 @@ function inflate(strm, flush) {
concerning the ENOUGH constants, which depend on those values */ concerning the ENOUGH constants, which depend on those values */
state.lenbits = 9; state.lenbits = 9;
opts = {bits: state.lenbits}; opts = { bits: state.lenbits };
ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);
// We have separate tables & no pointers. 2 commented lines below not needed. // We have separate tables & no pointers. 2 commented lines below not needed.
// state.next_index = opts.table_index; // state.next_index = opts.table_index;
@ -1851,7 +1854,7 @@ function inflate(strm, flush) {
//state.distcode.copy(state.codes); //state.distcode.copy(state.codes);
// Switch to use dynamic table // Switch to use dynamic table
state.distcode = state.distdyn; state.distcode = state.distdyn;
opts = {bits: state.distbits}; opts = { bits: state.distbits };
ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);
// We have separate tables & no pointers. 2 commented lines below not needed. // We have separate tables & no pointers. 2 commented lines below not needed.
// state.next_index = opts.table_index; // state.next_index = opts.table_index;
@ -1899,7 +1902,7 @@ function inflate(strm, flush) {
} }
state.back = 0; state.back = 0;
for (;;) { for (;;) {
here = state.lencode[hold & ((1 << state.lenbits) -1)]; /*BITS(state.lenbits)*/ here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/
here_bits = here >>> 24; here_bits = here >>> 24;
here_op = (here >>> 16) & 0xff; here_op = (here >>> 16) & 0xff;
here_val = here & 0xffff; here_val = here & 0xffff;
@ -1918,7 +1921,7 @@ function inflate(strm, flush) {
last_val = here_val; last_val = here_val;
for (;;) { for (;;) {
here = state.lencode[last_val + here = state.lencode[last_val +
((hold & ((1 << (last_bits + last_op)) -1))/*BITS(last.bits + last.op)*/ >> last_bits)]; ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
here_bits = here >>> 24; here_bits = here >>> 24;
here_op = (here >>> 16) & 0xff; here_op = (here >>> 16) & 0xff;
here_val = here & 0xffff; here_val = here & 0xffff;
@ -1975,7 +1978,7 @@ function inflate(strm, flush) {
bits += 8; bits += 8;
} }
//===// //===//
state.length += hold & ((1 << state.extra) -1)/*BITS(state.extra)*/; state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
//--- DROPBITS(state.extra) ---// //--- DROPBITS(state.extra) ---//
hold >>>= state.extra; hold >>>= state.extra;
bits -= state.extra; bits -= state.extra;
@ -1988,7 +1991,7 @@ function inflate(strm, flush) {
/* falls through */ /* falls through */
case DIST: case DIST:
for (;;) { for (;;) {
here = state.distcode[hold & ((1 << state.distbits) -1)];/*BITS(state.distbits)*/ here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/
here_bits = here >>> 24; here_bits = here >>> 24;
here_op = (here >>> 16) & 0xff; here_op = (here >>> 16) & 0xff;
here_val = here & 0xffff; here_val = here & 0xffff;
@ -2007,7 +2010,7 @@ function inflate(strm, flush) {
last_val = here_val; last_val = here_val;
for (;;) { for (;;) {
here = state.distcode[last_val + here = state.distcode[last_val +
((hold & ((1 << (last_bits + last_op)) -1))/*BITS(last.bits + last.op)*/ >> last_bits)]; ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
here_bits = here >>> 24; here_bits = here >>> 24;
here_op = (here >>> 16) & 0xff; here_op = (here >>> 16) & 0xff;
here_val = here & 0xffff; here_val = here & 0xffff;
@ -2051,7 +2054,7 @@ function inflate(strm, flush) {
bits += 8; bits += 8;
} }
//===// //===//
state.offset += hold & ((1 << state.extra) -1)/*BITS(state.extra)*/; state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
//--- DROPBITS(state.extra) ---// //--- DROPBITS(state.extra) ---//
hold >>>= state.extra; hold >>>= state.extra;
bits -= state.extra; bits -= state.extra;
@ -2145,8 +2148,8 @@ function inflate(strm, flush) {
} }
_out = left; _out = left;
// NB: crc32 stored as signed 32-bit int, ZSWAP32 returns signed too // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
if ((state.flags ? hold : ZSWAP32(hold)) !== state.check) { if ((state.flags ? hold : zswap32(hold)) !== state.check) {
strm.msg = 'incorrect data check'; strm.msg = 'incorrect data check';
state.mode = BAD; state.mode = BAD;
break; break;
@ -2350,8 +2353,8 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta
var base_index = 0; var base_index = 0;
// var shoextra; /* extra bits table to use */ // var shoextra; /* extra bits table to use */
var end; /* use base and extra for symbol > end */ var end; /* use base and extra for symbol > end */
var count = new utils.Buf16(MAXBITS+1); //[MAXBITS+1]; /* number of codes of each length */ var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */
var offs = new utils.Buf16(MAXBITS+1); //[MAXBITS+1]; /* offsets in table for each length */ var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */
var extra = null; var extra = null;
var extra_index = 0; var extra_index = 0;
@ -2520,7 +2523,7 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta
return 1; return 1;
} }
var i=0; var i = 0;
/* process all codes and make table entries */ /* process all codes and make table entries */
for (;;) { for (;;) {
i++; i++;
@ -2623,9 +2626,9 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta
'use strict'; 'use strict';
module.exports = { module.exports = {
'2': 'need dictionary', /* Z_NEED_DICT 2 */ 2: 'need dictionary', /* Z_NEED_DICT 2 */
'1': 'stream end', /* Z_STREAM_END 1 */ 1: 'stream end', /* Z_STREAM_END 1 */
'0': '', /* Z_OK 0 */ 0: '', /* Z_OK 0 */
'-1': 'file error', /* Z_ERRNO (-1) */ '-1': 'file error', /* Z_ERRNO (-1) */
'-2': 'stream error', /* Z_STREAM_ERROR (-2) */ '-2': 'stream error', /* Z_STREAM_ERROR (-2) */
'-3': 'data error', /* Z_DATA_ERROR (-3) */ '-3': 'data error', /* Z_DATA_ERROR (-3) */
@ -2669,13 +2672,13 @@ module.exports = ZStream;
'use strict'; 'use strict';
var zlib_inflate = require('./zlib/inflate.js'); var zlib_inflate = require('./zlib/inflate');
var utils = require('./utils/common'); var utils = require('./utils/common');
var strings = require('./utils/strings'); var strings = require('./utils/strings');
var c = require('./zlib/constants'); var c = require('./zlib/constants');
var msg = require('./zlib/messages'); var msg = require('./zlib/messages');
var zstream = require('./zlib/zstream'); var ZStream = require('./zlib/zstream');
var gzheader = require('./zlib/gzheader'); var GZheader = require('./zlib/gzheader');
var toString = Object.prototype.toString; var toString = Object.prototype.toString;
@ -2757,7 +2760,8 @@ var toString = Object.prototype.toString;
* console.log(inflate.result); * console.log(inflate.result);
* ``` * ```
**/ **/
var Inflate = function(options) { function Inflate(options) {
if (!(this instanceof Inflate)) return new Inflate(options);
this.options = utils.assign({ this.options = utils.assign({
chunkSize: 16384, chunkSize: 16384,
@ -2795,7 +2799,7 @@ var Inflate = function(options) {
this.ended = false; // used to avoid multiple onEnd() calls this.ended = false; // used to avoid multiple onEnd() calls
this.chunks = []; // chunks of compressed data this.chunks = []; // chunks of compressed data
this.strm = new zstream(); this.strm = new ZStream();
this.strm.avail_out = 0; this.strm.avail_out = 0;
var status = zlib_inflate.inflateInit2( var status = zlib_inflate.inflateInit2(
@ -2807,10 +2811,10 @@ var Inflate = function(options) {
throw new Error(msg[status]); throw new Error(msg[status]);
} }
this.header = new gzheader(); this.header = new GZheader();
zlib_inflate.inflateGetHeader(this.strm, this.header); zlib_inflate.inflateGetHeader(this.strm, this.header);
}; }
/** /**
* Inflate#push(data[, mode]) -> Boolean * Inflate#push(data[, mode]) -> Boolean
@ -2840,7 +2844,7 @@ var Inflate = function(options) {
* push(chunk, true); // push last chunk * push(chunk, true); // push last chunk
* ``` * ```
**/ **/
Inflate.prototype.push = function(data, mode) { Inflate.prototype.push = function (data, mode) {
var strm = this.strm; var strm = this.strm;
var chunkSize = this.options.chunkSize; var chunkSize = this.options.chunkSize;
var status, _mode; var status, _mode;
@ -2954,7 +2958,7 @@ Inflate.prototype.push = function(data, mode) {
* By default, stores data blocks in `chunks[]` property and glue * By default, stores data blocks in `chunks[]` property and glue
* those in `onEnd`. Override this handler, if you need another behaviour. * those in `onEnd`. Override this handler, if you need another behaviour.
**/ **/
Inflate.prototype.onData = function(chunk) { Inflate.prototype.onData = function (chunk) {
this.chunks.push(chunk); this.chunks.push(chunk);
}; };
@ -2969,7 +2973,7 @@ Inflate.prototype.onData = function(chunk) {
* or if an error happened. By default - join collected chunks, * or if an error happened. By default - join collected chunks,
* free memory and fill `results` / `err` properties. * free memory and fill `results` / `err` properties.
**/ **/
Inflate.prototype.onEnd = function(status) { Inflate.prototype.onEnd = function (status) {
// On success - join // On success - join
if (status === c.Z_OK) { if (status === c.Z_OK) {
if (this.options.to === 'string') { if (this.options.to === 'string') {
@ -3067,5 +3071,5 @@ exports.inflate = inflate;
exports.inflateRaw = inflateRaw; exports.inflateRaw = inflateRaw;
exports.ungzip = inflate; exports.ungzip = inflate;
},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate.js":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js") },{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")
}); });

File diff suppressed because one or more lines are too long