Socket
Socket
Sign inDemoInstall

@syncfusion/ej2-compression

Package Overview
Dependencies
1
Maintainers
3
Versions
97
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 17.2.49-beta to 17.2.52-1205479

README.md

9

dist/ej2-compression.umd.min.js

@@ -0,2 +1,11 @@

/*!
* filename: ej2-compression.umd.min.js
* version : 17.2.47
* Copyright Syncfusion Inc. 2001 - 2019. All rights reserved.
* Use of this code is subject to the terms of our license.
* A copy of the current license can be obtained at any time by e-mailing
* licensing@syncfusion.com. Any infringement will be prosecuted under
* applicable laws.
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@syncfusion/ej2-file-utils")):"function"==typeof define&&define.amd?define(["exports","@syncfusion/ej2-file-utils"],e):e(t.ej={},t.ej2FileUtils)}(this,function(t,e){"use strict";var i=new Int16Array(286),r=new Uint8Array(286),n=new Int16Array(30),s=new Uint8Array(30),h=function(){function t(e){this.pendingBuffer=new Uint8Array(65536),this.pendingBufLength=0,this.pendingBufCache=0,this.pendingBufBitsInCache=0,this.bufferPosition=0,this.extraBits=0,this.currentHash=0,this.matchStart=0,this.matchLength=0,this.matchPrevAvail=!1,this.blockStart=0,this.stringStart=0,this.lookAhead=0,this.totalBytesIn=0,this.inputOffset=0,this.inputEnd=0,this.windowSize=32768,this.windowMask=this.windowSize-1,this.hashSize=32768,this.hashMask=this.hashSize-1,this.hashShift=Math.floor(17/3),this.maxDist=this.windowSize-262,this.checkSum=1,this.noWrap=!1,t.isHuffmanTreeInitiated||(t.initHuffmanTree(),t.isHuffmanTreeInitiated=!0),this.treeLiteral=new o(this,286,257,15),this.treeDistances=new o(this,30,1,15),this.treeCodeLengths=new o(this,19,4,7),this.arrDistances=new Uint16Array(16384),this.arrLiterals=new Uint8Array(16384),this.stream=[],this.dataWindow=new Uint8Array(2*this.windowSize),this.hashHead=new Int16Array(this.hashSize),this.hashPrevious=new Int16Array(this.windowSize),this.blockStart=this.stringStart=1,this.noWrap=e,e||this.writeZLibHeader()}return Object.defineProperty(t.prototype,"compressedData",{get:function(){return this.stream},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"getCompressedString",{get:function(){var t="";if(void 0!==this.stream)for(var e=0;e<this.stream.length;e++)t+=String.fromCharCode.apply(null,this.stream[e]);return t},enumerable:!0,configurable:!0}),t.prototype.write=function(t,i,r){if(void 0===t||null===t)throw new Error("ArgumentException: data cannot null or undefined");var n=i+r;if(0>i||i>n||n>t.length)throw new Error("ArgumentOutOfRangeException: Offset or length is incorrect");if("string"==typeof t){var s=new e.Encoding(!1);s.type="Utf8",n=i+(t=new Uint8Array(s.getBytes(t,0,t.length))).length}for(this.inputBuffer=t,this.inputOffset=i,this.inputEnd=n,this.noWrap||(this.checkSum=a.checksumUpdate(this.checkSum,this.inputBuffer,this.inputOffset,n));this.inputEnd!==this.inputOffset||0!==this.pendingBufLength;)this.pendingBufferFlush(),this.compressData(!1)},t.prototype.writeZLibHeader=function(){var t=30720;t|=64,t+=31-t%31,this.pendingBufferWriteShortBytes(t)},t.prototype.pendingBufferWriteShortBytes=function(t){this.pendingBuffer[this.pendingBufLength++]=t>>8,this.pendingBuffer[this.pendingBufLength++]=t},t.prototype.compressData=function(t){var e;do{this.fillWindow();var i=t&&this.inputEnd===this.inputOffset;e=this.compressSlow(i,t)}while(0===this.pendingBufLength&&e);return e},t.prototype.compressSlow=function(t,e){if(this.lookAhead<262&&!t)return!1;for(;this.lookAhead>=262||t;){if(0===this.lookAhead)return this.lookAheadCompleted(e);this.stringStart>=2*this.windowSize-262&&this.slideWindow();var i=this.matchStart,r=this.matchLength;if(this.lookAhead>=3&&this.discardMatch(),r>=3&&this.matchLength<=r?r=this.matchPreviousBest(i,r):this.matchPreviousAvailable(),this.bufferPosition>=16384)return this.huffmanIsFull(e)}return!0},t.prototype.discardMatch=function(){var t=this.insertString();0!==t&&this.stringStart-t<=this.maxDist&&this.findLongestMatch(t)&&this.matchLength<=5&&3===this.matchLength&&this.stringStart-this.matchStart>4096&&(this.matchLength=2)},t.prototype.matchPreviousAvailable=function(){this.matchPrevAvail&&this.huffmanTallyLit(255&this.dataWindow[this.stringStart-1]),this.matchPrevAvail=!0,this.stringStart++,this.lookAhead--},t.prototype.matchPreviousBest=function(t,e){this.huffmanTallyDist(this.stringStart-1-t,e),e-=2;do{this.stringStart++,this.lookAhead--,this.lookAhead>=3&&this.insertString()}while(--e>0);return this.stringStart++,this.lookAhead--,this.matchPrevAvail=!1,this.matchLength=2,e},t.prototype.lookAheadCompleted=function(t){return this.matchPrevAvail&&this.huffmanTallyLit(255&this.dataWindow[this.stringStart-1]),this.matchPrevAvail=!1,this.huffmanFlushBlock(this.dataWindow,this.blockStart,this.stringStart-this.blockStart,t),this.blockStart=this.stringStart,!1},t.prototype.huffmanIsFull=function(t){var e=this.stringStart-this.blockStart;this.matchPrevAvail&&e--;var i=t&&0===this.lookAhead&&!this.matchPrevAvail;return this.huffmanFlushBlock(this.dataWindow,this.blockStart,e,i),this.blockStart+=e,!i},t.prototype.fillWindow=function(){for(this.stringStart>=this.windowSize+this.maxDist&&this.slideWindow();this.lookAhead<262&&this.inputOffset<this.inputEnd;){var t=2*this.windowSize-this.lookAhead-this.stringStart;t>this.inputEnd-this.inputOffset&&(t=this.inputEnd-this.inputOffset),this.dataWindow.set(this.inputBuffer.subarray(this.inputOffset,this.inputOffset+t),this.stringStart+this.lookAhead),this.inputOffset+=t,this.totalBytesIn+=t,this.lookAhead+=t}this.lookAhead>=3&&this.updateHash()},t.prototype.slideWindow=function(){this.dataWindow.set(this.dataWindow.subarray(this.windowSize,this.windowSize+this.windowSize),0),this.matchStart-=this.windowSize,this.stringStart-=this.windowSize,this.blockStart-=this.windowSize;for(var t=0;t<this.hashSize;++t){var e=65535&this.hashHead[t];this.hashHead[t]=e>=this.windowSize?e-this.windowSize:0}for(t=0;t<this.windowSize;t++){e=65535&this.hashPrevious[t];this.hashPrevious[t]=e>=this.windowSize?e-this.windowSize:0}},t.prototype.insertString=function(){var t,e=(this.currentHash<<this.hashShift^this.dataWindow[this.stringStart+2])&this.hashMask;return this.hashPrevious[this.stringStart&this.windowMask]=t=this.hashHead[e],this.hashHead[e]=this.stringStart,this.currentHash=e,65535&t},t.prototype.findLongestMatch=function(t){var e,i=4096,r=258,n=this.stringStart,s=this.stringStart+this.matchLength,h=Math.max(this.matchLength,2),o=Math.max(this.stringStart-this.maxDist,0),a=this.stringStart+258-1,f=this.dataWindow[s-1],u=this.dataWindow[s],d=this.dataWindow;h>=32&&(i>>=2),r>this.lookAhead&&(r=this.lookAhead);do{if(d[t+h]===u&&d[t+h-1]===f&&d[t]===d[n]&&d[t+1]===d[n+1]){for(e=t+2,n+=2;d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&n<a;);if(n>s){if(this.matchStart=t,s=n,(h=n-this.stringStart)>=r)break;f=d[s-1],u=d[s]}n=this.stringStart}}while((t=65535&this.hashPrevious[t&this.windowMask])>o&&0!=--i);return this.matchLength=Math.min(h,this.lookAhead),this.matchLength>=3},t.prototype.updateHash=function(){this.currentHash=this.dataWindow[this.stringStart]<<this.hashShift^this.dataWindow[this.stringStart+1]},t.prototype.huffmanTallyLit=function(t){return this.arrDistances[this.bufferPosition]=0,this.arrLiterals[this.bufferPosition++]=t,this.treeLiteral.codeFrequencies[t]++,this.bufferPosition>=16384},t.prototype.huffmanTallyDist=function(t,e){this.arrDistances[this.bufferPosition]=t,this.arrLiterals[this.bufferPosition++]=e-3;var i=this.huffmanLengthCode(e-3);this.treeLiteral.codeFrequencies[i]++,i>=265&&i<285&&(this.extraBits+=Math.floor((i-261)/4));var r=this.huffmanDistanceCode(t-1);return this.treeDistances.codeFrequencies[r]++,r>=4&&(this.extraBits+=Math.floor(r/2-1)),this.bufferPosition>=16384},t.prototype.huffmanFlushBlock=function(t,e,h,a){this.treeLiteral.codeFrequencies[256]++,this.treeLiteral.buildTree(),this.treeDistances.buildTree(),this.treeLiteral.calculateBLFreq(this.treeCodeLengths),this.treeDistances.calculateBLFreq(this.treeCodeLengths),this.treeCodeLengths.buildTree();for(var f=4,u=18;u>f;u--)this.treeCodeLengths.codeLengths[o.huffCodeLengthOrders[u]]>0&&(f=u+1);var d=14+3*f+this.treeCodeLengths.getEncodedLength()+this.treeLiteral.getEncodedLength()+this.treeDistances.getEncodedLength()+this.extraBits,c=this.extraBits;for(u=0;u<286;u++)c+=this.treeLiteral.codeFrequencies[u]*r[u];for(u=0;u<30;u++)c+=this.treeDistances.codeFrequencies[u]*s[u];d>=c&&(d=c),e>=0&&h+4<d>>3?this.huffmanFlushStoredBlock(t,e,h,a):d==c?(this.pendingBufferWriteBits(2+(a?1:0),3),this.treeLiteral.setStaticCodes(i,r),this.treeDistances.setStaticCodes(n,s),this.huffmanCompressBlock(),this.huffmanReset()):(this.pendingBufferWriteBits(4+(a?1:0),3),this.huffmanSendAllTrees(f),this.huffmanCompressBlock(),this.huffmanReset())},t.prototype.huffmanFlushStoredBlock=function(t,e,i,r){this.pendingBufferWriteBits(0+(r?1:0),3),this.pendingBufferAlignToByte(),this.pendingBufferWriteShort(i),this.pendingBufferWriteShort(~i),this.pendingBufferWriteByteBlock(t,e,i),this.huffmanReset()},t.prototype.huffmanLengthCode=function(t){if(255===t)return 285;for(var e=257;t>=8;)e+=4,t>>=1;return e+t},t.prototype.huffmanDistanceCode=function(t){for(var e=0;t>=4;)e+=2,t>>=1;return e+t},t.prototype.huffmanSendAllTrees=function(t){this.treeCodeLengths.buildCodes(),this.treeLiteral.buildCodes(),this.treeDistances.buildCodes(),this.pendingBufferWriteBits(this.treeLiteral.treeLength-257,5),this.pendingBufferWriteBits(this.treeDistances.treeLength-1,5),this.pendingBufferWriteBits(t-4,4);for(var e=0;e<t;e++)this.pendingBufferWriteBits(this.treeCodeLengths.codeLengths[o.huffCodeLengthOrders[e]],3);this.treeLiteral.writeTree(this.treeCodeLengths),this.treeDistances.writeTree(this.treeCodeLengths)},t.prototype.huffmanReset=function(){this.bufferPosition=0,this.extraBits=0,this.treeLiteral.reset(),this.treeDistances.reset(),this.treeCodeLengths.reset()},t.prototype.huffmanCompressBlock=function(){for(var t=0;t<this.bufferPosition;t++){var e=255&this.arrLiterals[t],i=this.arrDistances[t];if(0!=i--){var r=this.huffmanLengthCode(e);this.treeLiteral.writeCodeToStream(r);var n=Math.floor((r-261)/4);n>0&&n<=5&&this.pendingBufferWriteBits(e&(1<<n)-1,n);var s=this.huffmanDistanceCode(i);this.treeDistances.writeCodeToStream(s),(n=Math.floor(s/2-1))>0&&this.pendingBufferWriteBits(i&(1<<n)-1,n)}else this.treeLiteral.writeCodeToStream(e)}this.treeLiteral.writeCodeToStream(256)},t.prototype.pendingBufferWriteBits=function(t,e){var i=new Uint32Array(1);i[0]=this.pendingBufCache|t<<this.pendingBufBitsInCache,this.pendingBufCache=i[0],this.pendingBufBitsInCache+=e,this.pendingBufferFlushBits()},t.prototype.pendingBufferFlush=function(t){if(this.pendingBufferFlushBits(),this.pendingBufLength>0){var e=new Uint8Array(this.pendingBufLength);e.set(this.pendingBuffer.subarray(0,this.pendingBufLength),0),this.stream.push(e)}this.pendingBufLength=0},t.prototype.pendingBufferFlushBits=function(){for(var t=0;this.pendingBufBitsInCache>=8&&this.pendingBufLength<65536;)this.pendingBuffer[this.pendingBufLength++]=this.pendingBufCache,this.pendingBufCache>>=8,this.pendingBufBitsInCache-=8,t++;return t},t.prototype.pendingBufferWriteByteBlock=function(t,e,i){var r=t.subarray(e,e+i);this.pendingBuffer.set(r,this.pendingBufLength),this.pendingBufLength+=i},t.prototype.pendingBufferWriteShort=function(t){this.pendingBuffer[this.pendingBufLength++]=t,this.pendingBuffer[this.pendingBufLength++]=t>>8},t.prototype.pendingBufferAlignToByte=function(){this.pendingBufBitsInCache>0&&(this.pendingBuffer[this.pendingBufLength++]=this.pendingBufCache),this.pendingBufCache=0,this.pendingBufBitsInCache=0},t.initHuffmanTree=function(){for(var t=0;t<144;)i[t]=o.bitReverse(48+t<<8),r[t++]=8;for(;t<256;)i[t]=o.bitReverse(256+t<<7),r[t++]=9;for(;t<280;)i[t]=o.bitReverse(-256+t<<9),r[t++]=7;for(;t<286;)i[t]=o.bitReverse(-88+t<<8),r[t++]=8;for(t=0;t<30;t++)n[t]=o.bitReverse(t<<11),s[t]=5},t.prototype.close=function(){do{this.pendingBufferFlush(!0),this.compressData(!0)||(this.pendingBufferFlush(!0),this.pendingBufferAlignToByte(),this.noWrap||(this.pendingBufferWriteShortBytes(this.checkSum>>16),this.pendingBufferWriteShortBytes(65535&this.checkSum)),this.pendingBufferFlush(!0))}while(this.inputEnd!==this.inputOffset||0!==this.pendingBufLength)},t.prototype.destroy=function(){this.stream=[],this.stream=void 0,this.pendingBuffer=void 0,this.treeLiteral=void 0,this.treeDistances=void 0,this.treeCodeLengths=void 0,this.arrLiterals=void 0,this.arrDistances=void 0,this.hashHead=void 0,this.hashPrevious=void 0,this.dataWindow=void 0,this.inputBuffer=void 0,this.pendingBufLength=void 0,this.pendingBufCache=void 0,this.pendingBufBitsInCache=void 0,this.bufferPosition=void 0,this.extraBits=void 0,this.currentHash=void 0,this.matchStart=void 0,this.matchLength=void 0,this.matchPrevAvail=void 0,this.blockStart=void 0,this.stringStart=void 0,this.lookAhead=void 0,this.totalBytesIn=void 0,this.inputOffset=void 0,this.inputEnd=void 0,this.windowSize=void 0,this.windowMask=void 0,this.hashSize=void 0,this.hashMask=void 0,this.hashShift=void 0,this.maxDist=void 0,this.checkSum=void 0,this.noWrap=void 0},t.isHuffmanTreeInitiated=!1,t}(),o=function(){function t(t,e,i,r){this.writer=t,this.codeMinCount=i,this.maxLength=r,this.codeFrequency=new Uint16Array(e),this.lengthCount=new Int32Array(r)}return Object.defineProperty(t.prototype,"treeLength",{get:function(){return this.codeCount},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"codeLengths",{get:function(){return this.codeLength},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"codeFrequencies",{get:function(){return this.codeFrequency},enumerable:!0,configurable:!0}),t.prototype.setStaticCodes=function(t,e){var i=new Int16Array(t.length);i.set(t,0),this.codes=i;var r=new Uint8Array(e.length);r.set(e,0),this.codeLength=r},t.prototype.reset=function(){for(var t=0;t<this.codeFrequency.length;t++)this.codeFrequency[t]=0;this.codes=void 0,this.codeLength=void 0},t.prototype.writeCodeToStream=function(t){this.writer.pendingBufferWriteBits(65535&this.codes[t],this.codeLength[t])},t.prototype.buildCodes=function(){var e=new Int32Array(this.maxLength);this.codes=new Int16Array(this.codeCount);for(var i=0,r=0;r<this.maxLength;r++)e[r]=i,i+=this.lengthCount[r]<<15-r;for(var n=0;n<this.codeCount;n++){var s=this.codeLength[n];s>0&&(this.codes[n]=t.bitReverse(e[s-1]),e[s-1]+=1<<16-s)}},t.bitReverse=function(e){return t.reverseBits[15&e]<<12|t.reverseBits[e>>4&15]<<8|t.reverseBits[e>>8&15]<<4|t.reverseBits[e>>12]},t.prototype.getEncodedLength=function(){for(var t=0,e=0;e<this.codeFrequency.length;e++)t+=this.codeFrequency[e]*this.codeLength[e];return t},t.prototype.calculateBLFreq=function(t){for(var e,i,r,n=-1,s=0;s<this.codeCount;){r=1;var h=this.codeLength[s];for(0===h?(e=138,i=3):(e=6,i=3,n!==h&&(t.codeFrequency[h]++,r=0)),n=h,s++;s<this.codeCount&&n===this.codeLength[s]&&(s++,!(++r>=e)););r<i?t.codeFrequency[n]+=r:0!==n?t.codeFrequency[16]++:r<=10?t.codeFrequency[17]++:t.codeFrequency[18]++}},t.prototype.writeTree=function(t){for(var e,i,r,n=-1,s=0;s<this.codeCount;){r=1;var h=this.codeLength[s];for(0===h?(e=138,i=3):(e=6,i=3,n!==h&&(t.writeCodeToStream(h),r=0)),n=h,s++;s<this.codeCount&&n===this.codeLength[s]&&(s++,!(++r>=e)););if(r<i)for(;r-- >0;)t.writeCodeToStream(n);else 0!==n?(t.writeCodeToStream(16),this.writer.pendingBufferWriteBits(r-3,2)):r<=10?(t.writeCodeToStream(17),this.writer.pendingBufferWriteBits(r-3,3)):(t.writeCodeToStream(18),this.writer.pendingBufferWriteBits(r-11,7))}},t.prototype.buildTree=function(){for(var t=this.codeFrequency.length,e=new Int32Array(t),i=0,r=0,n=0;n<t;n++){var s=this.codeFrequency[n];if(0!==s){for(var h=i++,o=0;h>0&&this.codeFrequency[e[o=Math.floor((h-1)/2)]]>s;)e[h]=e[o],h=o;e[h]=n,r=n}}for(;i<2;)e[i++]=r<2?++r:0;this.codeCount=Math.max(r+1,this.codeMinCount);for(var a=i,f=new Int32Array(4*i-2),u=new Int32Array(2*i-1),d=0;d<i;d++){var c=e[d],l=2*d;f[l]=c,f[l+1]=-1,u[d]=this.codeFrequency[c]<<8,e[d]=d}this.constructHuffmanTree(e,i,u,a,f),this.buildLength(f)},t.prototype.constructHuffmanTree=function(t,e,i,r,n){do{for(var s=t[0],h=t[--e],o=i[h],a=0,f=1;f<e;)f+1<e&&i[t[f]]>i[t[f+1]]&&f++,t[a]=t[f],f=2*(a=f)+1;for(;(f=a)>0&&i[t[a=Math.floor((f-1)/2)]]>o;)t[f]=t[a];t[f]=h;var u=t[0];n[2*(h=r++)]=s,n[2*h+1]=u;var d=Math.min(255&i[s],255&i[u]);for(i[h]=o=i[s]+i[u]-d+1,a=0,f=1;f<e;)f+1<e&&i[t[f]]>i[t[f+1]]&&f++,t[a]=t[f],f=2*(a=f)+1;for(;(f=a)>0&&i[t[a=Math.floor((f-1)/2)]]>o;)t[f]=t[a];t[f]=h}while(e>1)},t.prototype.buildLength=function(t){this.codeLength=new Uint8Array(this.codeFrequency.length);for(var e=Math.floor(t.length/2),i=Math.floor((e+1)/2),r=0,n=0;n<this.maxLength;n++)this.lengthCount[n]=0;if(0!==(r=this.calculateOptimalCodeLength(t,r,e))){var s=this.maxLength-1;do{for(;0===this.lengthCount[--s];);do{this.lengthCount[s]--,this.lengthCount[++s]++,r-=1<<this.maxLength-1-s}while(r>0&&s<this.maxLength-1)}while(r>0);this.recreateTree(t,r,i)}},t.prototype.recreateTree=function(t,e,i){this.lengthCount[this.maxLength-1]+=e,this.lengthCount[this.maxLength-2]-=e;for(var r=2*i,n=this.maxLength;0!==n;n--)for(var s=this.lengthCount[n-1];s>0;){var h=2*t[r++];-1===t[h+1]&&(this.codeLength[t[h]]=n,s--)}},t.prototype.calculateOptimalCodeLength=function(t,e,i){var r=new Int32Array(i);r[i-1]=0;for(var n=i-1;n>=0;n--){var s=2*n+1;if(-1!==t[s]){(h=r[n]+1)>this.maxLength&&(h=this.maxLength,e++),r[t[s-1]]=r[t[s]]=h}else{var h=r[n];this.lengthCount[h-1]++,this.codeLength[t[s-1]]=r[n]}}return e},t.reverseBits=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],t.huffCodeLengthOrders=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],t}(),a=function(){function t(){}return t.checksumUpdate=function(e,i,r,n){var s=new Uint32Array(1);s[0]=e;for(var h=s[0],o=s[0]=65535&h,a=s[0]=h>>t.checkSumBitOffset;n>0;){var f=Math.min(n,t.checksumIterationCount);for(n-=f;--f>=0;)a+=o+=s[0]=255&i[r++];o%=t.checksumBase,a%=t.checksumBase}return h=a<<t.checkSumBitOffset|o},t.checkSumBitOffset=16,t.checksumBase=65521,t.checksumIterationCount=3800,t}(),f=[],u=function(){function t(){0===f.length&&t.initCrc32Table(),this.files=[],this.level="Normal",e.Save.isMicrosoftBrowser=!!navigator.msSaveBlob}return Object.defineProperty(t.prototype,"compressionLevel",{get:function(){return this.level},set:function(t){this.level=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return void 0===this.files?0:this.files.length},enumerable:!0,configurable:!0}),t.prototype.addItem=function(t){if(null===t||void 0===t)throw new Error("ArgumentException: item cannot be null or undefined");for(var e=0;e<this.files.length;e++){var i=this.files[e];if(i instanceof d&&i.name===t.name)throw new Error("item with same name already exist")}this.files.push(t)},t.prototype.addDirectory=function(t){if(null===t||void 0===t)throw new Error("ArgumentException: string cannot be null or undefined");if(0===t.length)throw new Error("ArgumentException: string cannot be empty");if("/"!==t.slice(-1)&&(t+="/"),-1!==this.files.indexOf(t))throw new Error("item with same name already exist");this.files.push(t)},t.prototype.getItem=function(t){if(t>=0&&t<this.files.length)return this.files[t]},t.prototype.contains=function(t){return-1!==this.files.indexOf(t)},t.prototype.save=function(t){if(null===t||void 0===t||0===t.length)throw new Error("ArgumentException: fileName cannot be null or undefined");if(0===this.files.length)throw new Error("InvalidOperation");var e=this;return new Promise(function(i,r){e.saveInternal(t,!1).then(function(){i(e)})})},t.prototype.saveAsBlob=function(){var t=this;return new Promise(function(e,i){t.saveInternal("",!0).then(function(t){e(t)})})},t.prototype.saveInternal=function(t,e){var i=this,r=this;return new Promise(function(n,s){for(var h=[],o=0,a=0;a<r.files.length;a++){i.getCompressedData(i.files[a]).then(function(i){if(o=r.constructZippedObject(h,i,o,i.isDirectory),h.length===r.files.length){var s=r.writeZippedContent(t,h,o,e);n(s)}})}})},t.prototype.destroy=function(){if(void 0!==this.files&&this.files.length>0){for(var t=0;t<this.files.length;t++){var e=this.files[t];e instanceof d&&e.destroy(),e=void 0}this.files=[]}this.files=void 0,this.level=void 0},t.prototype.getCompressedData=function(t){var e=this;return new Promise(function(i,r){if(t instanceof d){var n=new FileReader;n.onload=function(){var r=new Uint8Array(n.result),s={fileName:t.name,crc32Value:0,compressedData:[],compressedSize:void 0,uncompressedDataSize:r.length,compressionType:void 0,isDirectory:!1};if("Normal"===e.level){e.compressData(r,s,f);for(var h=0,o=0;o<s.compressedData.length;o++)h+=s.compressedData[o].length;s.compressedSize=h,s.compressionType="\b\0"}else s.compressedSize=r.length,s.crc32Value=e.calculateCrc32Value(0,r,f),s.compressionType="\0\0",s.compressedData.push(r);i(s)},n.readAsArrayBuffer(t.data)}else{i({fileName:t,crc32Value:0,compressedData:"",compressedSize:0,uncompressedDataSize:0,compressionType:"\0\0",isDirectory:!0})}})},t.prototype.compressData=function(t,e,i){var r=new h(!0),n=0,s=0;do{if(n>=t.length){r.close();break}s=Math.min(t.length,n+16384);var o=t.subarray(n,s);e.crc32Value=this.calculateCrc32Value(e.crc32Value,o,i),r.write(o,0,s-n),n=s}while(n<=t.length);e.compressedData=r.compressedData,r.destroy()},t.prototype.constructZippedObject=function(t,e,i,r){var n=0,s=new Date;r&&(n|=16),n|=0;var h=this.writeHeader(e,s),o="PK"+h+e.fileName,a=this.writeCentralDirectory(e,h,i,n);return t.push({localHeader:o,centralDir:a,compressedData:e}),i+o.length+e.compressedSize},t.prototype.writeHeader=function(t,e){var i="";return i+="\n\0\0\0",i+=t.compressionType,i+=this.getBytes(this.getModifiedTime(e),2),i+=this.getBytes(this.getModifiedDate(e),2),i+=this.getBytes(t.crc32Value,4),i+=this.getBytes(t.compressedSize,4),i+=this.getBytes(t.uncompressedDataSize,4),i+=this.getBytes(t.fileName.length,2),i+=this.getBytes(0,2)},t.prototype.writeZippedContent=function(t,i,r,n){for(var s=0,h=[],o=0;o<i.length;o++){var a=i[o];for(s+=a.centralDir.length,h.push(this.getArrayBuffer(a.localHeader));a.compressedData.compressedData.length;)h.push(a.compressedData.compressedData.shift().buffer)}for(o=0;o<i.length;o++)h.push(this.getArrayBuffer(i[o].centralDir));h.push(this.getArrayBuffer(this.writeFooter(i,s,r)));var f=new Blob(h,{type:"application/zip"});return n||e.Save.save(t,f),f},t.prototype.writeCentralDirectory=function(t,e,i,r){return"PK"+this.getBytes(20,2)+e+this.getBytes(0,2)+"\0\0\0\0"+this.getBytes(r,4)+this.getBytes(i,4)+t.fileName},t.prototype.writeFooter=function(t,e,i){return"PK\0\0\0\0"+this.getBytes(t.length,2)+this.getBytes(t.length,2)+this.getBytes(e,4)+this.getBytes(i,4)+this.getBytes(0,2)},t.prototype.getArrayBuffer=function(t){for(var e=new Uint8Array(t.length),i=0;i<t.length;++i)e[i]=255&t.charCodeAt(i);return e.buffer},t.prototype.getBytes=function(t,e){for(var i="",r=0;r<e;r++)i+=String.fromCharCode(255&t),t>>>=8;return i},t.prototype.getModifiedTime=function(t){var e=t.getHours();return e<<=6,e|=t.getMinutes(),e<<=5,e|=t.getSeconds()/2},t.prototype.getModifiedDate=function(t){var e=t.getFullYear()-1980;return e<<=4,e|=t.getMonth()+1,e<<=5,e|=t.getDate()},t.prototype.calculateCrc32Value=function(t,e,i){t^=-1;for(var r=0;r<e.length;r++)t=t>>>8^i[255&(t^e[r])];return-1^t},t.initCrc32Table=function(){for(var t,e=0;e<256;e++){t=e;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;f[e]=t}},t}(),d=function(){function t(t,e){if(null===t||void 0===t)throw new Error("ArgumentException: data cannot be null or undefined");if(null===e||void 0===e)throw new Error("ArgumentException: string cannot be null or undefined");if(0===e.length)throw new Error("string cannot be empty");this.data=t,this.name=e}return Object.defineProperty(t.prototype,"name",{get:function(){return this.fileName},set:function(t){this.fileName=t},enumerable:!0,configurable:!0}),t.prototype.destroy=function(){this.fileName=void 0,this.data=void 0},t}();t.ZipArchive=u,t.ZipArchiveItem=d,t.CompressedStreamWriter=h,t.CompressorHuffmanTree=o,t.ChecksumCalculator=a,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ej2-compression.umd.min.js.map

@@ -0,2 +1,11 @@

/*!
* filename: ej2-compression.min.js
* version : 17.2.47
* Copyright Syncfusion Inc. 2001 - 2019. All rights reserved.
* Use of this code is subject to the terms of our license.
* A copy of the current license can be obtained at any time by e-mailing
* licensing@syncfusion.com. Any infringement will be prosecuted under
* applicable laws.
*/
this.ej=this.ej||{},this.ej.compression=function(t,e){"use strict";var i=new Int16Array(286),r=new Uint8Array(286),n=new Int16Array(30),s=new Uint8Array(30),h=function(){function t(e){this.pendingBuffer=new Uint8Array(65536),this.pendingBufLength=0,this.pendingBufCache=0,this.pendingBufBitsInCache=0,this.bufferPosition=0,this.extraBits=0,this.currentHash=0,this.matchStart=0,this.matchLength=0,this.matchPrevAvail=!1,this.blockStart=0,this.stringStart=0,this.lookAhead=0,this.totalBytesIn=0,this.inputOffset=0,this.inputEnd=0,this.windowSize=32768,this.windowMask=this.windowSize-1,this.hashSize=32768,this.hashMask=this.hashSize-1,this.hashShift=Math.floor(17/3),this.maxDist=this.windowSize-262,this.checkSum=1,this.noWrap=!1,t.isHuffmanTreeInitiated||(t.initHuffmanTree(),t.isHuffmanTreeInitiated=!0),this.treeLiteral=new o(this,286,257,15),this.treeDistances=new o(this,30,1,15),this.treeCodeLengths=new o(this,19,4,7),this.arrDistances=new Uint16Array(16384),this.arrLiterals=new Uint8Array(16384),this.stream=[],this.dataWindow=new Uint8Array(2*this.windowSize),this.hashHead=new Int16Array(this.hashSize),this.hashPrevious=new Int16Array(this.windowSize),this.blockStart=this.stringStart=1,this.noWrap=e,e||this.writeZLibHeader()}return Object.defineProperty(t.prototype,"compressedData",{get:function(){return this.stream},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"getCompressedString",{get:function(){var t="";if(void 0!==this.stream)for(var e=0;e<this.stream.length;e++)t+=String.fromCharCode.apply(null,this.stream[e]);return t},enumerable:!0,configurable:!0}),t.prototype.write=function(t,i,r){if(void 0===t||null===t)throw new Error("ArgumentException: data cannot null or undefined");var n=i+r;if(0>i||i>n||n>t.length)throw new Error("ArgumentOutOfRangeException: Offset or length is incorrect");if("string"==typeof t){var s=new e.Encoding(!1);s.type="Utf8",n=i+(t=new Uint8Array(s.getBytes(t,0,t.length))).length}for(this.inputBuffer=t,this.inputOffset=i,this.inputEnd=n,this.noWrap||(this.checkSum=a.checksumUpdate(this.checkSum,this.inputBuffer,this.inputOffset,n));this.inputEnd!==this.inputOffset||0!==this.pendingBufLength;)this.pendingBufferFlush(),this.compressData(!1)},t.prototype.writeZLibHeader=function(){var t=30720;t|=64,t+=31-t%31,this.pendingBufferWriteShortBytes(t)},t.prototype.pendingBufferWriteShortBytes=function(t){this.pendingBuffer[this.pendingBufLength++]=t>>8,this.pendingBuffer[this.pendingBufLength++]=t},t.prototype.compressData=function(t){var e;do{this.fillWindow();var i=t&&this.inputEnd===this.inputOffset;e=this.compressSlow(i,t)}while(0===this.pendingBufLength&&e);return e},t.prototype.compressSlow=function(t,e){if(this.lookAhead<262&&!t)return!1;for(;this.lookAhead>=262||t;){if(0===this.lookAhead)return this.lookAheadCompleted(e);this.stringStart>=2*this.windowSize-262&&this.slideWindow();var i=this.matchStart,r=this.matchLength;if(this.lookAhead>=3&&this.discardMatch(),r>=3&&this.matchLength<=r?r=this.matchPreviousBest(i,r):this.matchPreviousAvailable(),this.bufferPosition>=16384)return this.huffmanIsFull(e)}return!0},t.prototype.discardMatch=function(){var t=this.insertString();0!==t&&this.stringStart-t<=this.maxDist&&this.findLongestMatch(t)&&this.matchLength<=5&&3===this.matchLength&&this.stringStart-this.matchStart>4096&&(this.matchLength=2)},t.prototype.matchPreviousAvailable=function(){this.matchPrevAvail&&this.huffmanTallyLit(255&this.dataWindow[this.stringStart-1]),this.matchPrevAvail=!0,this.stringStart++,this.lookAhead--},t.prototype.matchPreviousBest=function(t,e){this.huffmanTallyDist(this.stringStart-1-t,e),e-=2;do{this.stringStart++,--this.lookAhead>=3&&this.insertString()}while(--e>0);return this.stringStart++,this.lookAhead--,this.matchPrevAvail=!1,this.matchLength=2,e},t.prototype.lookAheadCompleted=function(t){return this.matchPrevAvail&&this.huffmanTallyLit(255&this.dataWindow[this.stringStart-1]),this.matchPrevAvail=!1,this.huffmanFlushBlock(this.dataWindow,this.blockStart,this.stringStart-this.blockStart,t),this.blockStart=this.stringStart,!1},t.prototype.huffmanIsFull=function(t){var e=this.stringStart-this.blockStart;this.matchPrevAvail&&e--;var i=t&&0===this.lookAhead&&!this.matchPrevAvail;return this.huffmanFlushBlock(this.dataWindow,this.blockStart,e,i),this.blockStart+=e,!i},t.prototype.fillWindow=function(){for(this.stringStart>=this.windowSize+this.maxDist&&this.slideWindow();this.lookAhead<262&&this.inputOffset<this.inputEnd;){var t=2*this.windowSize-this.lookAhead-this.stringStart;t>this.inputEnd-this.inputOffset&&(t=this.inputEnd-this.inputOffset),this.dataWindow.set(this.inputBuffer.subarray(this.inputOffset,this.inputOffset+t),this.stringStart+this.lookAhead),this.inputOffset+=t,this.totalBytesIn+=t,this.lookAhead+=t}this.lookAhead>=3&&this.updateHash()},t.prototype.slideWindow=function(){this.dataWindow.set(this.dataWindow.subarray(this.windowSize,this.windowSize+this.windowSize),0),this.matchStart-=this.windowSize,this.stringStart-=this.windowSize,this.blockStart-=this.windowSize;for(t=0;t<this.hashSize;++t){e=65535&this.hashHead[t];this.hashHead[t]=e>=this.windowSize?e-this.windowSize:0}for(var t=0;t<this.windowSize;t++){var e=65535&this.hashPrevious[t];this.hashPrevious[t]=e>=this.windowSize?e-this.windowSize:0}},t.prototype.insertString=function(){var t,e=(this.currentHash<<this.hashShift^this.dataWindow[this.stringStart+2])&this.hashMask;return this.hashPrevious[this.stringStart&this.windowMask]=t=this.hashHead[e],this.hashHead[e]=this.stringStart,this.currentHash=e,65535&t},t.prototype.findLongestMatch=function(t){var e,i=4096,r=258,n=this.stringStart,s=this.stringStart+this.matchLength,h=Math.max(this.matchLength,2),o=Math.max(this.stringStart-this.maxDist,0),a=this.stringStart+258-1,f=this.dataWindow[s-1],u=this.dataWindow[s],d=this.dataWindow;h>=32&&(i>>=2),r>this.lookAhead&&(r=this.lookAhead);do{if(d[t+h]===u&&d[t+h-1]===f&&d[t]===d[n]&&d[t+1]===d[n+1]){for(e=t+2,n+=2;d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&d[++n]===d[++e]&&n<a;);if(n>s){if(this.matchStart=t,s=n,(h=n-this.stringStart)>=r)break;f=d[s-1],u=d[s]}n=this.stringStart}}while((t=65535&this.hashPrevious[t&this.windowMask])>o&&0!=--i);return this.matchLength=Math.min(h,this.lookAhead),this.matchLength>=3},t.prototype.updateHash=function(){this.currentHash=this.dataWindow[this.stringStart]<<this.hashShift^this.dataWindow[this.stringStart+1]},t.prototype.huffmanTallyLit=function(t){return this.arrDistances[this.bufferPosition]=0,this.arrLiterals[this.bufferPosition++]=t,this.treeLiteral.codeFrequencies[t]++,this.bufferPosition>=16384},t.prototype.huffmanTallyDist=function(t,e){this.arrDistances[this.bufferPosition]=t,this.arrLiterals[this.bufferPosition++]=e-3;var i=this.huffmanLengthCode(e-3);this.treeLiteral.codeFrequencies[i]++,i>=265&&i<285&&(this.extraBits+=Math.floor((i-261)/4));var r=this.huffmanDistanceCode(t-1);return this.treeDistances.codeFrequencies[r]++,r>=4&&(this.extraBits+=Math.floor(r/2-1)),this.bufferPosition>=16384},t.prototype.huffmanFlushBlock=function(t,e,h,a){this.treeLiteral.codeFrequencies[256]++,this.treeLiteral.buildTree(),this.treeDistances.buildTree(),this.treeLiteral.calculateBLFreq(this.treeCodeLengths),this.treeDistances.calculateBLFreq(this.treeCodeLengths),this.treeCodeLengths.buildTree();for(var f=4,u=18;u>f;u--)this.treeCodeLengths.codeLengths[o.huffCodeLengthOrders[u]]>0&&(f=u+1);for(var d=14+3*f+this.treeCodeLengths.getEncodedLength()+this.treeLiteral.getEncodedLength()+this.treeDistances.getEncodedLength()+this.extraBits,c=this.extraBits,u=0;u<286;u++)c+=this.treeLiteral.codeFrequencies[u]*r[u];for(u=0;u<30;u++)c+=this.treeDistances.codeFrequencies[u]*s[u];d>=c&&(d=c),e>=0&&h+4<d>>3?this.huffmanFlushStoredBlock(t,e,h,a):d==c?(this.pendingBufferWriteBits(2+(a?1:0),3),this.treeLiteral.setStaticCodes(i,r),this.treeDistances.setStaticCodes(n,s),this.huffmanCompressBlock(),this.huffmanReset()):(this.pendingBufferWriteBits(4+(a?1:0),3),this.huffmanSendAllTrees(f),this.huffmanCompressBlock(),this.huffmanReset())},t.prototype.huffmanFlushStoredBlock=function(t,e,i,r){this.pendingBufferWriteBits(0+(r?1:0),3),this.pendingBufferAlignToByte(),this.pendingBufferWriteShort(i),this.pendingBufferWriteShort(~i),this.pendingBufferWriteByteBlock(t,e,i),this.huffmanReset()},t.prototype.huffmanLengthCode=function(t){if(255===t)return 285;for(var e=257;t>=8;)e+=4,t>>=1;return e+t},t.prototype.huffmanDistanceCode=function(t){for(var e=0;t>=4;)e+=2,t>>=1;return e+t},t.prototype.huffmanSendAllTrees=function(t){this.treeCodeLengths.buildCodes(),this.treeLiteral.buildCodes(),this.treeDistances.buildCodes(),this.pendingBufferWriteBits(this.treeLiteral.treeLength-257,5),this.pendingBufferWriteBits(this.treeDistances.treeLength-1,5),this.pendingBufferWriteBits(t-4,4);for(var e=0;e<t;e++)this.pendingBufferWriteBits(this.treeCodeLengths.codeLengths[o.huffCodeLengthOrders[e]],3);this.treeLiteral.writeTree(this.treeCodeLengths),this.treeDistances.writeTree(this.treeCodeLengths)},t.prototype.huffmanReset=function(){this.bufferPosition=0,this.extraBits=0,this.treeLiteral.reset(),this.treeDistances.reset(),this.treeCodeLengths.reset()},t.prototype.huffmanCompressBlock=function(){for(var t=0;t<this.bufferPosition;t++){var e=255&this.arrLiterals[t],i=this.arrDistances[t];if(0!=i--){var r=this.huffmanLengthCode(e);this.treeLiteral.writeCodeToStream(r);var n=Math.floor((r-261)/4);n>0&&n<=5&&this.pendingBufferWriteBits(e&(1<<n)-1,n);var s=this.huffmanDistanceCode(i);this.treeDistances.writeCodeToStream(s),(n=Math.floor(s/2-1))>0&&this.pendingBufferWriteBits(i&(1<<n)-1,n)}else this.treeLiteral.writeCodeToStream(e)}this.treeLiteral.writeCodeToStream(256)},t.prototype.pendingBufferWriteBits=function(t,e){var i=new Uint32Array(1);i[0]=this.pendingBufCache|t<<this.pendingBufBitsInCache,this.pendingBufCache=i[0],this.pendingBufBitsInCache+=e,this.pendingBufferFlushBits()},t.prototype.pendingBufferFlush=function(t){if(this.pendingBufferFlushBits(),this.pendingBufLength>0){var e=new Uint8Array(this.pendingBufLength);e.set(this.pendingBuffer.subarray(0,this.pendingBufLength),0),this.stream.push(e)}this.pendingBufLength=0},t.prototype.pendingBufferFlushBits=function(){for(var t=0;this.pendingBufBitsInCache>=8&&this.pendingBufLength<65536;)this.pendingBuffer[this.pendingBufLength++]=this.pendingBufCache,this.pendingBufCache>>=8,this.pendingBufBitsInCache-=8,t++;return t},t.prototype.pendingBufferWriteByteBlock=function(t,e,i){var r=t.subarray(e,e+i);this.pendingBuffer.set(r,this.pendingBufLength),this.pendingBufLength+=i},t.prototype.pendingBufferWriteShort=function(t){this.pendingBuffer[this.pendingBufLength++]=t,this.pendingBuffer[this.pendingBufLength++]=t>>8},t.prototype.pendingBufferAlignToByte=function(){this.pendingBufBitsInCache>0&&(this.pendingBuffer[this.pendingBufLength++]=this.pendingBufCache),this.pendingBufCache=0,this.pendingBufBitsInCache=0},t.initHuffmanTree=function(){for(var t=0;t<144;)i[t]=o.bitReverse(48+t<<8),r[t++]=8;for(;t<256;)i[t]=o.bitReverse(256+t<<7),r[t++]=9;for(;t<280;)i[t]=o.bitReverse(-256+t<<9),r[t++]=7;for(;t<286;)i[t]=o.bitReverse(-88+t<<8),r[t++]=8;for(t=0;t<30;t++)n[t]=o.bitReverse(t<<11),s[t]=5},t.prototype.close=function(){do{this.pendingBufferFlush(!0),this.compressData(!0)||(this.pendingBufferFlush(!0),this.pendingBufferAlignToByte(),this.noWrap||(this.pendingBufferWriteShortBytes(this.checkSum>>16),this.pendingBufferWriteShortBytes(65535&this.checkSum)),this.pendingBufferFlush(!0))}while(this.inputEnd!==this.inputOffset||0!==this.pendingBufLength)},t.prototype.destroy=function(){this.stream=[],this.stream=void 0,this.pendingBuffer=void 0,this.treeLiteral=void 0,this.treeDistances=void 0,this.treeCodeLengths=void 0,this.arrLiterals=void 0,this.arrDistances=void 0,this.hashHead=void 0,this.hashPrevious=void 0,this.dataWindow=void 0,this.inputBuffer=void 0,this.pendingBufLength=void 0,this.pendingBufCache=void 0,this.pendingBufBitsInCache=void 0,this.bufferPosition=void 0,this.extraBits=void 0,this.currentHash=void 0,this.matchStart=void 0,this.matchLength=void 0,this.matchPrevAvail=void 0,this.blockStart=void 0,this.stringStart=void 0,this.lookAhead=void 0,this.totalBytesIn=void 0,this.inputOffset=void 0,this.inputEnd=void 0,this.windowSize=void 0,this.windowMask=void 0,this.hashSize=void 0,this.hashMask=void 0,this.hashShift=void 0,this.maxDist=void 0,this.checkSum=void 0,this.noWrap=void 0},t.isHuffmanTreeInitiated=!1,t}(),o=function(){function t(t,e,i,r){this.writer=t,this.codeMinCount=i,this.maxLength=r,this.codeFrequency=new Uint16Array(e),this.lengthCount=new Int32Array(r)}return Object.defineProperty(t.prototype,"treeLength",{get:function(){return this.codeCount},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"codeLengths",{get:function(){return this.codeLength},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"codeFrequencies",{get:function(){return this.codeFrequency},enumerable:!0,configurable:!0}),t.prototype.setStaticCodes=function(t,e){var i=new Int16Array(t.length);i.set(t,0),this.codes=i;var r=new Uint8Array(e.length);r.set(e,0),this.codeLength=r},t.prototype.reset=function(){for(var t=0;t<this.codeFrequency.length;t++)this.codeFrequency[t]=0;this.codes=void 0,this.codeLength=void 0},t.prototype.writeCodeToStream=function(t){this.writer.pendingBufferWriteBits(65535&this.codes[t],this.codeLength[t])},t.prototype.buildCodes=function(){var e=new Int32Array(this.maxLength);this.codes=new Int16Array(this.codeCount);for(var i=0,r=0;r<this.maxLength;r++)e[r]=i,i+=this.lengthCount[r]<<15-r;for(var n=0;n<this.codeCount;n++){var s=this.codeLength[n];s>0&&(this.codes[n]=t.bitReverse(e[s-1]),e[s-1]+=1<<16-s)}},t.bitReverse=function(e){return t.reverseBits[15&e]<<12|t.reverseBits[e>>4&15]<<8|t.reverseBits[e>>8&15]<<4|t.reverseBits[e>>12]},t.prototype.getEncodedLength=function(){for(var t=0,e=0;e<this.codeFrequency.length;e++)t+=this.codeFrequency[e]*this.codeLength[e];return t},t.prototype.calculateBLFreq=function(t){for(var e,i,r,n=-1,s=0;s<this.codeCount;){r=1;var h=this.codeLength[s];for(0===h?(e=138,i=3):(e=6,i=3,n!==h&&(t.codeFrequency[h]++,r=0)),n=h,s++;s<this.codeCount&&n===this.codeLength[s]&&(s++,!(++r>=e)););r<i?t.codeFrequency[n]+=r:0!==n?t.codeFrequency[16]++:r<=10?t.codeFrequency[17]++:t.codeFrequency[18]++}},t.prototype.writeTree=function(t){for(var e,i,r,n=-1,s=0;s<this.codeCount;){r=1;var h=this.codeLength[s];for(0===h?(e=138,i=3):(e=6,i=3,n!==h&&(t.writeCodeToStream(h),r=0)),n=h,s++;s<this.codeCount&&n===this.codeLength[s]&&(s++,!(++r>=e)););if(r<i)for(;r-- >0;)t.writeCodeToStream(n);else 0!==n?(t.writeCodeToStream(16),this.writer.pendingBufferWriteBits(r-3,2)):r<=10?(t.writeCodeToStream(17),this.writer.pendingBufferWriteBits(r-3,3)):(t.writeCodeToStream(18),this.writer.pendingBufferWriteBits(r-11,7))}},t.prototype.buildTree=function(){for(var t=this.codeFrequency.length,e=new Int32Array(t),i=0,r=0,n=0;n<t;n++){var s=this.codeFrequency[n];if(0!==s){for(var h=i++,o=0;h>0&&this.codeFrequency[e[o=Math.floor((h-1)/2)]]>s;)e[h]=e[o],h=o;e[h]=n,r=n}}for(;i<2;)e[i++]=r<2?++r:0;this.codeCount=Math.max(r+1,this.codeMinCount);for(var a=i,f=new Int32Array(4*i-2),u=new Int32Array(2*i-1),d=0;d<i;d++){var c=e[d],p=2*d;f[p]=c,f[p+1]=-1,u[d]=this.codeFrequency[c]<<8,e[d]=d}this.constructHuffmanTree(e,i,u,a,f),this.buildLength(f)},t.prototype.constructHuffmanTree=function(t,e,i,r,n){do{for(var s=t[0],h=t[--e],o=i[h],a=0,f=1;f<e;)f+1<e&&i[t[f]]>i[t[f+1]]&&f++,t[a]=t[f],f=2*(a=f)+1;for(;(f=a)>0&&i[t[a=Math.floor((f-1)/2)]]>o;)t[f]=t[a];t[f]=h;var u=t[0];n[2*(h=r++)]=s,n[2*h+1]=u;var d=Math.min(255&i[s],255&i[u]);for(i[h]=o=i[s]+i[u]-d+1,a=0,f=1;f<e;)f+1<e&&i[t[f]]>i[t[f+1]]&&f++,t[a]=t[f],f=2*(a=f)+1;for(;(f=a)>0&&i[t[a=Math.floor((f-1)/2)]]>o;)t[f]=t[a];t[f]=h}while(e>1)},t.prototype.buildLength=function(t){this.codeLength=new Uint8Array(this.codeFrequency.length);for(var e=Math.floor(t.length/2),i=Math.floor((e+1)/2),r=0,n=0;n<this.maxLength;n++)this.lengthCount[n]=0;if(0!==(r=this.calculateOptimalCodeLength(t,r,e))){var s=this.maxLength-1;do{for(;0===this.lengthCount[--s];);do{this.lengthCount[s]--,this.lengthCount[++s]++,r-=1<<this.maxLength-1-s}while(r>0&&s<this.maxLength-1)}while(r>0);this.recreateTree(t,r,i)}},t.prototype.recreateTree=function(t,e,i){this.lengthCount[this.maxLength-1]+=e,this.lengthCount[this.maxLength-2]-=e;for(var r=2*i,n=this.maxLength;0!==n;n--)for(var s=this.lengthCount[n-1];s>0;){var h=2*t[r++];-1===t[h+1]&&(this.codeLength[t[h]]=n,s--)}},t.prototype.calculateOptimalCodeLength=function(t,e,i){var r=new Int32Array(i);r[i-1]=0;for(var n=i-1;n>=0;n--){var s=2*n+1;if(-1!==t[s])(h=r[n]+1)>this.maxLength&&(h=this.maxLength,e++),r[t[s-1]]=r[t[s]]=h;else{var h=r[n];this.lengthCount[h-1]++,this.codeLength[t[s-1]]=r[n]}}return e},t.reverseBits=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],t.huffCodeLengthOrders=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],t}(),a=function(){function t(){}return t.checksumUpdate=function(e,i,r,n){var s=new Uint32Array(1);s[0]=e;for(var h=s[0],o=s[0]=65535&h,a=s[0]=h>>t.checkSumBitOffset;n>0;){var f=Math.min(n,t.checksumIterationCount);for(n-=f;--f>=0;)a+=o+=s[0]=255&i[r++];o%=t.checksumBase,a%=t.checksumBase}return h=a<<t.checkSumBitOffset|o},t.checkSumBitOffset=16,t.checksumBase=65521,t.checksumIterationCount=3800,t}(),f=[],u=function(){function t(){0===f.length&&t.initCrc32Table(),this.files=[],this.level="Normal",e.Save.isMicrosoftBrowser=!!navigator.msSaveBlob}return Object.defineProperty(t.prototype,"compressionLevel",{get:function(){return this.level},set:function(t){this.level=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return void 0===this.files?0:this.files.length},enumerable:!0,configurable:!0}),t.prototype.addItem=function(t){if(null===t||void 0===t)throw new Error("ArgumentException: item cannot be null or undefined");for(var e=0;e<this.files.length;e++){var i=this.files[e];if(i instanceof d&&i.name===t.name)throw new Error("item with same name already exist")}this.files.push(t)},t.prototype.addDirectory=function(t){if(null===t||void 0===t)throw new Error("ArgumentException: string cannot be null or undefined");if(0===t.length)throw new Error("ArgumentException: string cannot be empty");if("/"!==t.slice(-1)&&(t+="/"),-1!==this.files.indexOf(t))throw new Error("item with same name already exist");this.files.push(t)},t.prototype.getItem=function(t){if(t>=0&&t<this.files.length)return this.files[t]},t.prototype.contains=function(t){return-1!==this.files.indexOf(t)},t.prototype.save=function(t){if(null===t||void 0===t||0===t.length)throw new Error("ArgumentException: fileName cannot be null or undefined");if(0===this.files.length)throw new Error("InvalidOperation");var e=this;return new Promise(function(i,r){e.saveInternal(t,!1).then(function(){i(e)})})},t.prototype.saveAsBlob=function(){var t=this;return new Promise(function(e,i){t.saveInternal("",!0).then(function(t){e(t)})})},t.prototype.saveInternal=function(t,e){var i=this,r=this;return new Promise(function(n,s){for(var h=[],o=0,a=0;a<r.files.length;a++)i.getCompressedData(i.files[a]).then(function(i){if(o=r.constructZippedObject(h,i,o,i.isDirectory),h.length===r.files.length){var s=r.writeZippedContent(t,h,o,e);n(s)}})})},t.prototype.destroy=function(){if(void 0!==this.files&&this.files.length>0){for(var t=0;t<this.files.length;t++){var e=this.files[t];e instanceof d&&e.destroy(),e=void 0}this.files=[]}this.files=void 0,this.level=void 0},t.prototype.getCompressedData=function(t){var e=this;return new Promise(function(i,r){if(t instanceof d){var n=new FileReader;n.onload=function(){var r=new Uint8Array(n.result),s={fileName:t.name,crc32Value:0,compressedData:[],compressedSize:void 0,uncompressedDataSize:r.length,compressionType:void 0,isDirectory:!1};if("Normal"===e.level){e.compressData(r,s,f);for(var h=0,o=0;o<s.compressedData.length;o++)h+=s.compressedData[o].length;s.compressedSize=h,s.compressionType="\b\0"}else s.compressedSize=r.length,s.crc32Value=e.calculateCrc32Value(0,r,f),s.compressionType="\0\0",s.compressedData.push(r);i(s)},n.readAsArrayBuffer(t.data)}else i({fileName:t,crc32Value:0,compressedData:"",compressedSize:0,uncompressedDataSize:0,compressionType:"\0\0",isDirectory:!0})})},t.prototype.compressData=function(t,e,i){var r=new h(!0),n=0,s=0;do{if(n>=t.length){r.close();break}s=Math.min(t.length,n+16384);var o=t.subarray(n,s);e.crc32Value=this.calculateCrc32Value(e.crc32Value,o,i),r.write(o,0,s-n),n=s}while(n<=t.length);e.compressedData=r.compressedData,r.destroy()},t.prototype.constructZippedObject=function(t,e,i,r){var n=0,s=new Date;r&&(n|=16),n|=0;var h=this.writeHeader(e,s),o="PK"+h+e.fileName,a=this.writeCentralDirectory(e,h,i,n);return t.push({localHeader:o,centralDir:a,compressedData:e}),i+o.length+e.compressedSize},t.prototype.writeHeader=function(t,e){var i="";return i+="\n\0\0\0",i+=t.compressionType,i+=this.getBytes(this.getModifiedTime(e),2),i+=this.getBytes(this.getModifiedDate(e),2),i+=this.getBytes(t.crc32Value,4),i+=this.getBytes(t.compressedSize,4),i+=this.getBytes(t.uncompressedDataSize,4),i+=this.getBytes(t.fileName.length,2),i+=this.getBytes(0,2)},t.prototype.writeZippedContent=function(t,i,r,n){for(var s=0,h=[],o=0;o<i.length;o++){var a=i[o];for(s+=a.centralDir.length,h.push(this.getArrayBuffer(a.localHeader));a.compressedData.compressedData.length;)h.push(a.compressedData.compressedData.shift().buffer)}for(o=0;o<i.length;o++)h.push(this.getArrayBuffer(i[o].centralDir));h.push(this.getArrayBuffer(this.writeFooter(i,s,r)));var f=new Blob(h,{type:"application/zip"});return n||e.Save.save(t,f),f},t.prototype.writeCentralDirectory=function(t,e,i,r){return"PK"+this.getBytes(20,2)+e+this.getBytes(0,2)+"\0\0\0\0"+this.getBytes(r,4)+this.getBytes(i,4)+t.fileName},t.prototype.writeFooter=function(t,e,i){return"PK\0\0\0\0"+this.getBytes(t.length,2)+this.getBytes(t.length,2)+this.getBytes(e,4)+this.getBytes(i,4)+this.getBytes(0,2)},t.prototype.getArrayBuffer=function(t){for(var e=new Uint8Array(t.length),i=0;i<t.length;++i)e[i]=255&t.charCodeAt(i);return e.buffer},t.prototype.getBytes=function(t,e){for(var i="",r=0;r<e;r++)i+=String.fromCharCode(255&t),t>>>=8;return i},t.prototype.getModifiedTime=function(t){var e=t.getHours();return e<<=6,e|=t.getMinutes(),e<<=5,e|=t.getSeconds()/2},t.prototype.getModifiedDate=function(t){var e=t.getFullYear()-1980;return e<<=4,e|=t.getMonth()+1,e<<=5,e|=t.getDate()},t.prototype.calculateCrc32Value=function(t,e,i){t^=-1;for(var r=0;r<e.length;r++)t=t>>>8^i[255&(t^e[r])];return-1^t},t.initCrc32Table=function(){for(var t,e=0;e<256;e++){t=e;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;f[e]=t}},t}(),d=function(){function t(t,e){if(null===t||void 0===t)throw new Error("ArgumentException: data cannot be null or undefined");if(null===e||void 0===e)throw new Error("ArgumentException: string cannot be null or undefined");if(0===e.length)throw new Error("string cannot be empty");this.data=t,this.name=e}return Object.defineProperty(t.prototype,"name",{get:function(){return this.fileName},set:function(t){this.fileName=t},enumerable:!0,configurable:!0}),t.prototype.destroy=function(){this.fileName=void 0,this.data=void 0},t}();return t.ZipArchive=u,t.ZipArchiveItem=d,t.CompressedStreamWriter=h,t.CompressorHuffmanTree=o,t.ChecksumCalculator=a,t}({},ej.fileutils),this.ejs=ej;
//# sourceMappingURL=ej2-compression.min.js.map

@@ -0,1 +1,10 @@

/*!
* filename: index.d.ts
* version : 17.2.47
* Copyright Syncfusion Inc. 2001 - 2019. All rights reserved.
* Use of this code is subject to the terms of our license.
* A copy of the current license can be obtained at any time by e-mailing
* licensing@syncfusion.com. Any infringement will be prosecuted under
* applicable laws.
*/
import * as _compression from '@syncfusion/ej2-compression';

@@ -2,0 +11,0 @@

65

package.json
{
"name": "@syncfusion/ej2-compression",
"version": "17.2.49-beta",
"_from": "@syncfusion/ej2-compression@~17.2.47",
"_id": "@syncfusion/ej2-compression@17.2.47",
"_inBundle": false,
"_integrity": "sha512-zJApwRGe8WBwnIp8rRJ643/mGWp6U35zBxfL3KksRWlMS71hvTE21SxPBYmcpZrgCEuY1H7QchdL6JGYvt7Jxw==",
"_location": "/@syncfusion/ej2-compression",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@syncfusion/ej2-compression@~17.2.47",
"name": "@syncfusion/ej2-compression",
"escapedName": "@syncfusion%2fej2-compression",
"scope": "@syncfusion",
"rawSpec": "~17.2.47",
"saveSpec": null,
"fetchSpec": "~17.2.47"
},
"_requiredBy": [
"/@syncfusion/ej2",
"/@syncfusion/ej2-charts",
"/@syncfusion/ej2-documenteditor",
"/@syncfusion/ej2-excel-export",
"/@syncfusion/ej2-grids",
"/@syncfusion/ej2-maps",
"/@syncfusion/ej2-pdf-export",
"/@syncfusion/ej2-pivotview",
"/@syncfusion/ej2-treemap"
],
"_resolved": "https://registry.npmjs.org/@syncfusion/ej2-compression/-/ej2-compression-17.2.47.tgz",
"_shasum": "de288d1e71989feb9abb010c664f8406fb17a114",
"_spec": "@syncfusion/ej2-compression@~17.2.47",
"_where": "D:\\today\\cusom pub;ish\\node_modules\\@syncfusion\\ej2",
"author": {
"name": "Syncfusion Inc."
},
"bugs": {
"url": "https://github.com/syncfusion/ej2-javascript-ui-controls/issues"
},
"bundleDependencies": false,
"dependencies": {
"@syncfusion/ej2-file-utils": "~17.2.52-1205479"
},
"deprecated": false,
"description": "Essential Javascript 2 Compression library",
"devDependencies": {},
"es2015": "./dist/es6/ej2-compression.es2015.js",
"homepage": "https://github.com/syncfusion/ej2-javascript-ui-controls#readme",
"keywords": [

@@ -13,16 +57,13 @@ "ej2",

],
"author": "Syncfusion Inc.",
"license": "UNLICENSED",
"dependencies": {
"@syncfusion/ej2-file-utils": "17.2.49-beta"
},
"devDependencies": {},
"main": "./dist/ej2-compression.umd.min.js",
"module": "./index.js",
"name": "@syncfusion/ej2-compression",
"repository": {
"type": "git",
"url": "https://github.com/syncfusion/ej2-javascript-ui-controls.git"
"url": "git+https://github.com/syncfusion/ej2-javascript-ui-controls.git"
},
"main": "./dist/ej2-compression.umd.min.js",
"module": "./index.js",
"es2015": "./dist/es6/ej2-compression.es2015.js",
"typings": "index.d.ts"
"sideEffects": false,
"typings": "index.d.ts",
"version": "17.2.52-1205479"
}
ReadMe.md
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc