From 9d91c93c24d644e663d5f5bd737f6132df98a1ca Mon Sep 17 00:00:00 2001 From: ukyo Date: Wed, 26 Mar 2014 16:49:55 +0900 Subject: [PATCH] defun defun function defines a function that can recieve arguments as object. --- jsziptools.js | 6 +++--- src/ZipArchiveWriter.js | 9 ++++----- src/algorithms/crc32.js | 9 ++++----- src/algorithms/deflate.js | 7 +++---- src/algorithms/inflate.js | 7 +++---- src/gz.compress.js | 17 ++++++++--------- src/gz.decompress.js | 12 +++++------- src/jsziptools.js | 14 ++++++++++++++ src/stream/algorithms/deflate.js | 14 +++++++++----- src/stream/algorithms/inflate.js | 13 ++++++++----- src/stream/gz.compress.js | 15 +++++---------- src/stream/gz.decompress.js | 11 ++++------- src/stream/zip.pack.js | 15 +++++++-------- src/stream/zlib.compress.js | 14 +++++++++----- src/stream/zlib.decompress.js | 13 ++++++++----- src/zip.pack.js | 13 ++++++------- src/zip.unpack.js | 21 ++++++++++++--------- src/zlib.compress.js | 7 +++---- src/zlib.decompress.js | 7 +++---- 19 files changed, 118 insertions(+), 106 deletions(-) diff --git a/jsziptools.js b/jsziptools.js index 1a430e2..5020ac7 100644 --- a/jsziptools.js +++ b/jsziptools.js @@ -2,7 +2,7 @@ * jsziptools.js 2.4.1 - MIT License. https://github.com/ukyo/jsziptools/blob/master/LICENSE * ES6-Promises - MIT License. https://github.com/jakearchibald/ES6-Promises/blob/master/LICENSE */ -;(function(){!function(a){var b,c,d,e;!function(){var a={},f={};b=function(b,c,d){a[b]={deps:c,callback:d}},e=d=c=function(b){function d(a){if("."!==a.charAt(0))return a;for(var c=a.split("/"),d=b.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(e._eak_seen=a,f[b])return f[b];if(f[b]={},!a[b])throw new Error("Could not find module "+b);for(var g,h=a[b],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)"exports"===i[l]?k.push(g={}):k.push(c(d(i[l])));var n=j.apply(this,k);return f[b]=g||n}}(),b("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;je;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(e._eak_seen=a,f[b])return f[b];if(f[b]={},!a[b])throw new Error("Could not find module "+b);for(var g,h=a[b],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)k.push("exports"===i[l]?g={}:c(d(i[l])));var n=j.apply(this,k);return f[b]=g||n}}(),b("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;j>1}function ZipArchiveReader(a){this.bytes=utils.toBytes(a.buffer),this.buffer=this.bytes.buffer,this.params=a}function ZipArchiveReaderBlob(a){this.blob=a.buffer,this.params=a}var utils={},algorithms={},gz={},zip={},env={},zpipe={},stream={algorithms:{},zlib:{},gz:{},zip:{}},global=this;zip.LOCAL_FILE_SIGNATURE=67324752,zip.CENTRAL_DIR_SIGNATURE=33639248,zip.END_SIGNATURE=101010256,env.isWorker="function"==typeof importScripts,expose("jz.algos",algorithms),expose("jz.stream.algos",stream.algorithms),utils.toArray=function(a){return Array.prototype.slice.call(a)},utils.getParams=function(a,b){if("[object Object]"===Object.prototype.toString.call(a[0]))return a[0];var c={};return b.forEach(function(b,d){c[b]=a[d]}),c},utils.toBytes=function(a){switch(Object.prototype.toString.call(a)){case"[object String]":return utils.stringToBytes(a);case"[object Array]":case"[object ArrayBuffer]":return new Uint8Array(a);case"[object Uint8Array]":return a;case"[object Int8Array]":case"[object Uint8ClampedArray]":case"[object CanvasPixelArray]":return new Uint8Array(a.buffer,a.byteOffset,a.byteLength);default:throw new Error("jz.utils.toBytes: not supported type.")}},expose("jz.utils.toBytes",utils.toBytes),utils.readFileAs=function(a,b,c){var d;return d=env.isWorker?function(d){var e=new FileReaderSync;d(e["readAs"+a].call(e,b,c))}:function(d,e){var f=new FileReader;f.onload=function(){d(f.result)},f.onerror=e,f["readAs"+a].call(f,b,c)},new Promise(d)},utils.readFileAsText=function(a,b){return utils.readFileAs("Text",a,b||"UTF-8")},utils.readFileAsArrayBuffer=utils.readFileAs.bind(null,"ArrayBuffer"),utils.readFileAsDataURL=utils.readFileAs.bind(null,"DataURL"),utils.readFileAsBinaryString=utils.readFileAs.bind(null,"BinaryString"),expose("jz.utils.readFileAsArrayBuffer",utils.readFileAsArrayBuffer),expose("jz.utils.readFileAsText",utils.readFileAsText),expose("jz.utils.readFileAsDataURL",utils.readFileAsDataURL),expose("jz.utils.readFileAsBinaryString",utils.readFileAsBinaryString),utils.stringToBytes=function(a){var b,c,d,e=a.length,f=-1,g=32,h=new Uint8Array(g);for(b=0;e>b;++b)c=a.charCodeAt(b),127>=c?h[++f]=c:2047>=c?(h[++f]=192|c>>>6,h[++f]=128|63&c):65535>=c?(h[++f]=224|c>>>12,h[++f]=128|c>>>6&63,h[++f]=128|63&c):(h[++f]=240|c>>>18,h[++f]=128|c>>>12&63,h[++f]=128|c>>>6&63,h[++f]=128|63&c),4>=g-f&&(d=h,g*=2,h=new Uint8Array(g),h.set(d));return h.subarray(0,++f)},utils.bytesToString=function(a,b){return utils.readFileAsText(new Blob([utils.toBytes(a)]),b)},expose("jz.utils.bytesToString",utils.bytesToString),utils.bytesToStringSync=null,env.isWorker&&(utils.bytesToStringSync=function(a,b){return(new FileReaderSync).readAsText(new Blob([utils.toBytes(a)]),b||"UTF-8")},expose("jz.utils.bytesToStringSync",utils.bytesToStringSync)),utils.detectEncoding=function(a){a=utils.toBytes(a);for(var b=0,c=a.length;c>b;++b)if(!(a[b]<128))if(192===(224&a[b])){if(128===(192&a[++b]))continue}else if(224===(240&a[b])){if(128===(192&a[++b])&&128===(192&a[++b]))continue}else{if(240!==(248&a[b]))return"Shift_JIS";if(128===(192&a[++b])&&128===(192&a[++b])&&128===(192&a[++b]))continue}return"UTF-8"},expose("jz.utils.detectEncoding",utils.detectEncoding),Promise.prototype.spread=function(a,b){return Promise.prototype.then.call(this,Function.prototype.apply.bind(a,null),b)},utils.load=function(a){return a=Array.isArray(a)?a:utils.toArray(arguments),Promise.all(a.map(function(a){return new Promise(function(b,c){var d=new XMLHttpRequest;d.open("GET",a),d.responseType="arraybuffer",d.onloadend=function(){var e=d.status;200===e||206===e||0===e?b(new Uint8Array(d.response)):c(new Error("Load Error: "+e+" "+a))},d.onerror=c,d.send()})}))},expose("jz.utils.load",utils.load),utils.concatBytes=function(a){var b,c,d,a=Array.isArray(a)?a:utils.toArray(arguments),e=0,f=0;for(b=0,c=a.length;c>b;++b)e+=a[b].length;for(d=new Uint8Array(e),b=0;c>b;++b)d.set(a[b],f),f+=a[b].length;return d},expose("jz.utils.concatBytes",utils.concatBytes),algorithms.adler32=function(a){for(var b,a=utils.toBytes(a),c=1,d=0,e=0,f=65521,g=a.length;g>0;){b=g>5550?5550:g,g-=b;do c+=a[e++],d+=c;while(--b);c%=f,d%=f}return(d<<16|c)>>>0},expose("jz.algorithms.adler32",algorithms.adler32),algorithms.crc32=function(){var a=function(){var a,b,c,d=3988292384,e=new Uint32Array(256);for(b=0;256>b;++b){for(a=b,c=0;8>c;++c)a=1&a?a>>>1^d:a>>>1;e[b]=a>>>0}return e}();return function(b,c){for(var d=utils.getParams(arguments,["buffer","crc"]),e=utils.toBytes(d.buffer),c=null==d.crc?4294967295:~d.crc>>>0,f=0,g=e.length,h=a;g>f;++f)c=c>>>8^h[e[f]^255&c];return~c>>>0}}(),expose("jz.algorithms.crc32",algorithms.crc32),algorithms.deflate=function(){var a=utils.getParams(arguments,["buffer","level","chunkSize"]);return zlib.rawDeflate(utils.toBytes(a.buffer),a.level,a.chunkSize)},expose("jz.algorithms.deflate",algorithms.deflate),algorithms.inflate=function(){var a=utils.getParams(arguments,["buffer","chunkSize"]);return zlib.rawInflate(utils.toBytes(a.buffer),a.chunkSize)},expose("jz.algorithms.inflate",algorithms.inflate),ZipArchiveWriter.prototype.write=function(a,b,c){var d=this;return a.split("/").reduce(function(a,b){return d.writeDir(a+"/"),a+"/"+b}),this.writeFile(a,b,c),this},ZipArchiveWriter.prototype.writeDir=function(a){var b;return a+=/.+\/$/.test(a)?"":"/",this.dirs[a]||(this.dirs[a]=!0,a=utils.toBytes(a),b=createLocalFileHeader(a,this.date,!1),this.centralDirHeaders.push(createCentralDirHeader(a,this.date,!1,this.offset,0,0,0)),this.trigger("data",b),this.offset+=b.length),this},ZipArchiveWriter.prototype.writeFile=function(a,b,c){a=utils.toBytes(a);var d=this.offset,e=createLocalFileHeader(a,this.date,c),f=0,g=this;return this.trigger("data",e),c?stream.algorithms.deflate({buffer:b,level:c,streamFn:function(a){f+=a.length,g.trigger("data",a)},shareMemory:this.shareMemory,chunkSize:this.chunkSize}):(f=b.length,this.trigger("data",b)),this.centralDirHeaders.push(createCentralDirHeader(a,this.date,c,d,b.length,f,algorithms.crc32(b))),this.offset+=e.length+f,this},ZipArchiveWriter.prototype.writeEnd=function(){var a=0,b=this;this.centralDirHeaders.forEach(function(c){a+=c.length,b.trigger("data",c)}),this.trigger("data",createEndCentDirHeader(this.centralDirHeaders.length,a,this.offset)),this.trigger("end",null)},ZipArchiveWriter.prototype.on=function(a,b){return this.listners[a]||(this.listners[a]=[]),this.listners[a].push(b),this},ZipArchiveWriter.prototype.trigger=function(a,b){this.listners[a]&&this.listners[a].forEach(function(a){a(b)})},expose("jz.zip.ZipArchiveWriter",ZipArchiveWriter),exposeProperty("write",ZipArchiveWriter,ZipArchiveWriter.prototype.write),exposeProperty("writeDir",ZipArchiveWriter,ZipArchiveWriter.prototype.writeDir),exposeProperty("writeFile",ZipArchiveWriter,ZipArchiveWriter.prototype.writeFile),exposeProperty("writeEnd",ZipArchiveWriter,ZipArchiveWriter.prototype.writeEnd),exposeProperty("on",ZipArchiveWriter,ZipArchiveWriter.prototype.on),stream.algorithms.deflate=function(){var a=utils.getParams(arguments,["buffer","streamFn","level","shareMemory","chunkSize"]);a.input=utils.toBytes(a.buffer),zlib.stream.rawDeflate(a)},expose("jz.stream.algorithms.deflate",stream.algorithms.deflate),stream.algorithms.inflate=function(){var a=utils.getParams(arguments,["buffer","streamFn","shareMemory","chunkSize"]);a.input=utils.toBytes(a.buffer),zlib.stream.rawInflate(a)},expose("jz.stream.algorithms.inflate",stream.algorithms.inflate),stream.zlib.compress=function(){var a=utils.getParams(arguments,["buffer","streamFn","level","shareMemory","chunkSize"]);a.input=utils.toBytes(a.buffer),zlib.stream.deflate(a)},expose("jz.stream.zlib.compress",stream.zlib.compress),stream.zlib.decompress=function(){var a=utils.getParams(arguments,["buffer","streamFn","shareMemory","chunkSize"]);a.input=utils.toBytes(a.buffer),zlib.stream.inflate(a)},expose("jz.stream.zlib.decompress",stream.zlib.decompress),stream.gz.compress=function(a,b,c,d,e,f,g){var h,i,j,k=utils.getParams(arguments,["buffer","streamFn","level","shareMemory","chunkSize","fname","fcomment"]),l=utils.toBytes(k.buffer),b=(k.level,k.streamFn),d=k.shareMemory,e=k.chunkSize,f=k.fname&&utils.toBytes(k.fname),g=k.fcomment&&utils.toBytes(k.fcomment),m=0,n=10,o=0,p=Date.now();f&&(n+=f.length+1,m|=8),g&&(n+=g.length+1,m|=16),h=new Uint8Array(n),j=new DataView(h.buffer),j.setUint32(o,529205248|m),o+=4,j.setUint32(o,p,!0),o+=4,j.setUint16(o,1279),o+=2,f&&(h.set(f,o),o+=f.length,h[o++]=0),g&&(h.set(g,o),o+=g.length,h[o++]=0),b(h),stream.algorithms.deflate({buffer:l,streamFn:b,shareMemory:d,chunkSize:e}),i=new Uint8Array(8),j=new DataView(i.buffer),j.setUint32(0,algorithms.crc32(l),!0),j.setUint32(4,l.length,!0),b(i)},expose("jz.stream.gz.compress",stream.gz.compress),stream.gz.decompress=function(a,b,c,d){var e,f,g=utils.getParams(arguments,["buffer","streamFn","shareMemory","chunkSize"]),h=utils.toBytes(g.buffer),b=g.streamFn,c=g.shareMemory,d=g.chunkSize,i=10,j=new DataView(h.buffer,h.byteOffset,h.byteLength);if(8075!==j.getUint16(0))throw new Error("jz.gz.decompress: invalid gzip file.");if(8!==h[2])throw new Error("jz.gz.decompress: not deflate.");if(e=h[3],4&e&&(i+=j.getUint16(i,!0)+2),8&e)for(;h[i++];);if(16&e)for(;h[i++];);if(2&e&&(i+=2),stream.algorithms.inflate({buffer:h.subarray(i,h.length-8),streamFn:function(a){f=algorithms.crc32(a,f),b(a)},shareMemory:c,chunkSize:d}),f!==j.getUint32(h.length-8,!0))throw new Error("js.stream.gz.decompress: file is broken.")},expose("jz.stream.gz.decompress",stream.gz.decompress),stream.zip.pack=function(){function a(b,c,d){var f,g=d.children||d.dir||d.folder;if(b="number"==typeof d.level?d.level:b,g)c+=d.name+(/.+\/$/.test(d.name)?"":"/"),e.writeDir(c),g.forEach(a.bind(null,b,c));else{if(null!=d.buffer&&(f=d.buffer),null!=d.str&&(f=d.str),null==f)throw new Error("jz.zip.pack: This type is not supported.");c+=d.name,e.writeFile(c,utils.toBytes(f),b)}}function b(a){var c=a.children||a.dir||a.folder;c?c.forEach(b):a.url&&d.push(utils.load(a.url).then(function(b){a.buffer=b[0],a.url=null}))}var c=utils.getParams(arguments,["files","streamFn","level","shareMemory","chunkSize"]),d=[],e=new ZipArchiveWriter(c);return e.on("data",c.streamFn),c.files.forEach(b),Promise.all(d).then(function(){c.files.forEach(a.bind(null,c.level,"")),e.writeEnd()})},expose("jz.stream.zip.pack",stream.zip.pack),expose("jz.zlib.compress",function(){var a=utils.getParams(arguments,["buffer","level","chunkSize"]);return zlib.deflate(utils.toBytes(a.buffer),a.level,a.chunkSize)}),expose("jz.zlib.decompress",function(){var a=utils.getParams(arguments,["buffer","chunkSize"]);return zlib.inflate(utils.toBytes(a.buffer),a.chunkSize)}),gz.compress=function(){var a=utils.getParams(arguments,["buffer","level","chunkSize","fname","fcomment"]),b=[];return stream.gz.compress({buffer:a.buffer,level:a.level,chunkSize:a.chunkSize,fname:a.fname,fcomment:a.fcomments,streamFn:function(a){b.push(a)}}),utils.concatBytes(b)},expose("jz.gz.compress",gz.compress),gz.decompress=function(){var a=utils.getParams(arguments,["buffer","chunkSize"]),b=[];return stream.gz.decompress({buffer:a.buffer,streamFn:function(a){b.push(a)},shareMemory:!1,chunkSize:a.chunkSize}),utils.concatBytes(b)},expose("jz.gz.decompress",gz.decompress),zip.pack=function(){var a=utils.getParams(arguments,["files","level","chunkSize"]),b=[];return stream.zip.pack({files:a.files,shareMemory:!1,level:a.level,chunkSize:a.chunkSize,streamFn:function(a){b.push(a)}}).then(function(){return utils.concatBytes(b)})},expose("jz.zip.pack",zip.pack);var mimetypes=function(){var a="application/epub+zip epub\napplication/x-gzip gz\napplication/andrew-inset ez\napplication/annodex anx\napplication/atom+xml atom\napplication/atomcat+xml atomcat\napplication/atomserv+xml atomsrv\napplication/bbolin lin\napplication/cap cap pcap\napplication/cu-seeme cu\napplication/davmount+xml davmount\napplication/dsptype tsp\napplication/ecmascript es\napplication/futuresplash spl\napplication/hta hta\napplication/java-archive jar\napplication/java-serialized-object ser\napplication/java-vm class\napplication/javascript js\napplication/json json\napplication/m3g m3g\napplication/mac-binhex40 hqx\napplication/mac-compactpro cpt\napplication/mathematica nb nbp\napplication/msaccess mdb\napplication/msword doc dot\napplication/mxf mxf\napplication/octet-stream bin\napplication/oda oda\napplication/ogg ogx\napplication/onenote one onetoc2 onetmp onepkg\napplication/pdf pdf\napplication/pgp-keys key\napplication/pgp-signature pgp\napplication/pics-rules prf\napplication/postscript ps ai eps epsi epsf eps2 eps3\napplication/rar rar\napplication/rdf+xml rdf\napplication/rss+xml rss\napplication/rtf rtf\napplication/sla stl\napplication/smil smi smil\napplication/xhtml+xml xhtml xht\napplication/xml xml xsl xsd\napplication/xspf+xml xspf\napplication/zip zip\napplication/vnd.android.package-archive apk\napplication/vnd.cinderella cdy\napplication/vnd.google-earth.kml+xml kml\napplication/vnd.google-earth.kmz kmz\napplication/vnd.mozilla.xul+xml xul\napplication/vnd.ms-excel xls xlb xlt\napplication/vnd.ms-excel.addin.macroEnabled.12 xlam\napplication/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb\napplication/vnd.ms-excel.sheet.macroEnabled.12 xlsm\napplication/vnd.ms-excel.template.macroEnabled.12 xltm\napplication/vnd.ms-officetheme thmx\napplication/vnd.ms-pki.seccat cat\napplication/vnd.ms-powerpoint ppt pps\napplication/vnd.ms-powerpoint.addin.macroEnabled.12 ppam\napplication/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm\napplication/vnd.ms-powerpoint.slide.macroEnabled.12 sldm\napplication/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm\napplication/vnd.ms-powerpoint.template.macroEnabled.12 potm\napplication/vnd.ms-word.document.macroEnabled.12 docm\napplication/vnd.ms-word.template.macroEnabled.12 dotm\napplication/vnd.oasis.opendocument.chart odc\napplication/vnd.oasis.opendocument.database odb\napplication/vnd.oasis.opendocument.formula odf\napplication/vnd.oasis.opendocument.graphics odg\napplication/vnd.oasis.opendocument.graphics-template otg\napplication/vnd.oasis.opendocument.image odi\napplication/vnd.oasis.opendocument.presentation odp\napplication/vnd.oasis.opendocument.presentation-template otp\napplication/vnd.oasis.opendocument.spreadsheet ods\napplication/vnd.oasis.opendocument.spreadsheet-template ots\napplication/vnd.oasis.opendocument.text odt\napplication/vnd.oasis.opendocument.text-master odm\napplication/vnd.oasis.opendocument.text-template ott\napplication/vnd.oasis.opendocument.text-web oth\napplication/vnd.openxmlformats-officedocument.presentationml.presentation pptx\napplication/vnd.openxmlformats-officedocument.presentationml.slide sldx\napplication/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx\napplication/vnd.openxmlformats-officedocument.presentationml.template potx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.template xltx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.template xltx\napplication/vnd.openxmlformats-officedocument.wordprocessingml.document docx\napplication/vnd.openxmlformats-officedocument.wordprocessingml.template dotx\napplication/vnd.rim.cod cod\napplication/vnd.smaf mmf\napplication/vnd.stardivision.calc sdc\napplication/vnd.stardivision.chart sds\napplication/vnd.stardivision.draw sda\napplication/vnd.stardivision.impress sdd\napplication/vnd.stardivision.math sdf\napplication/vnd.stardivision.writer sdw\napplication/vnd.stardivision.writer-global sgl\napplication/vnd.sun.xml.calc sxc\napplication/vnd.sun.xml.calc.template stc\napplication/vnd.sun.xml.draw sxd\napplication/vnd.sun.xml.draw.template std\napplication/vnd.sun.xml.impress sxi\napplication/vnd.sun.xml.impress.template sti\napplication/vnd.sun.xml.math sxm\napplication/vnd.sun.xml.writer sxw\napplication/vnd.sun.xml.writer.global sxg\napplication/vnd.sun.xml.writer.template stw\napplication/vnd.symbian.install sis\napplication/vnd.visio vsd\napplication/vnd.wap.wbxml wbxml\napplication/vnd.wap.wmlc wmlc\napplication/vnd.wap.wmlscriptc wmlsc\napplication/vnd.wordperfect wpd\napplication/vnd.wordperfect5.1 wp5\napplication/x-123 wk\napplication/x-7z-compressed 7z\napplication/x-abiword abw\napplication/x-apple-diskimage dmg\napplication/x-bcpio bcpio\napplication/x-bittorrent torrent\napplication/x-cab cab\napplication/x-cbr cbr\napplication/x-cbz cbz\napplication/x-cdf cdf cda\napplication/x-cdlink vcd\napplication/x-chess-pgn pgn\napplication/x-comsol mph\napplication/x-cpio cpio\napplication/x-csh csh\napplication/x-debian-package deb udeb\napplication/x-director dcr dir dxr\napplication/x-dms dms\napplication/x-doom wad\napplication/x-dvi dvi\napplication/x-font pfa pfb gsf pcf pcf.Z\napplication/x-freemind mm\napplication/x-futuresplash spl\napplication/x-ganttproject gan\napplication/x-gnumeric gnumeric\napplication/x-go-sgf sgf\napplication/x-graphing-calculator gcf\napplication/x-gtar gtar\napplication/x-gtar-compressed tgz taz\napplication/x-hdf hdf\napplication/x-httpd-eruby rhtml\napplication/x-httpd-php phtml pht php\napplication/x-httpd-php-source phps\napplication/x-httpd-php3 php3\napplication/x-httpd-php3-preprocessed php3p\napplication/x-httpd-php4 php4\napplication/x-httpd-php5 php5\napplication/x-ica ica\napplication/x-info info\napplication/x-internet-signup ins isp\napplication/x-iphone iii\napplication/x-iso9660-image iso\napplication/x-jam jam\napplication/x-java-jnlp-file jnlp\napplication/x-jmol jmz\napplication/x-kchart chrt\napplication/x-killustrator kil\napplication/x-koan skp skd skt skm\napplication/x-kpresenter kpr kpt\napplication/x-kspread ksp\napplication/x-kword kwd kwt\napplication/x-latex latex\napplication/x-lha lha\napplication/x-lyx lyx\napplication/x-lzh lzh\napplication/x-lzx lzx\napplication/x-maker frm maker frame fm fb book fbdoc\napplication/x-mif mif\napplication/x-mpegURL m3u8\napplication/x-ms-wmd wmd\napplication/x-ms-wmz wmz\napplication/x-msdos-program com exe bat dll\napplication/x-msi msi\napplication/x-netcdf nc\napplication/x-ns-proxy-autoconfig pac dat\napplication/x-nwc nwc\napplication/x-object o\napplication/x-oz-application oza\napplication/x-pkcs7-certreqresp p7r\napplication/x-pkcs7-crl crl\napplication/x-python-code pyc pyo\napplication/x-qgis qgs shp shx\napplication/x-quicktimeplayer qtl\napplication/x-rdp rdp\napplication/x-redhat-package-manager rpm\napplication/x-ruby rb\napplication/x-scilab sci sce\napplication/x-sh sh\napplication/x-shar shar\napplication/x-shockwave-flash swf swfl\napplication/x-silverlight scr\napplication/x-sql sql\napplication/x-stuffit sit sitx\napplication/x-sv4cpio sv4cpio\napplication/x-sv4crc sv4crc\napplication/x-tar tar\napplication/x-tcl tcl\napplication/x-tex-gf gf\napplication/x-tex-pk pk\napplication/x-texinfo texinfo texi\napplication/x-trash ~ % bak old sik\napplication/x-troff t tr roff\napplication/x-troff-man man\napplication/x-troff-me me\napplication/x-troff-ms ms\napplication/x-ustar ustar\napplication/x-wais-source src\napplication/x-wingz wz\napplication/x-x509-ca-cert crt\napplication/x-xcf xcf\napplication/x-xfig fig\napplication/x-xpinstall xpi\naudio/amr amr\naudio/amr-wb awb\naudio/amr amr\naudio/amr-wb awb\naudio/annodex axa\naudio/basic au snd\naudio/csound csd orc sco\naudio/flac flac\naudio/midi mid midi kar\naudio/mpeg mpga mpega mp2 mp3 m4a\naudio/mpegurl m3u\naudio/ogg oga ogg spx\naudio/prs.sid sid\naudio/x-aiff aif aiff aifc\naudio/x-gsm gsm\naudio/x-mpegurl m3u\naudio/x-ms-wma wma\naudio/x-ms-wax wax\naudio/x-pn-realaudio ra rm ram\naudio/x-realaudio ra\naudio/x-scpls pls\naudio/x-sd2 sd2\naudio/x-wav wav\nchemical/x-alchemy alc\nchemical/x-cache cac cache\nchemical/x-cache-csf csf\nchemical/x-cactvs-binary cbin cascii ctab\nchemical/x-cdx cdx\nchemical/x-cerius cer\nchemical/x-chem3d c3d\nchemical/x-chemdraw chm\nchemical/x-cif cif\nchemical/x-cmdf cmdf\nchemical/x-cml cml\nchemical/x-compass cpa\nchemical/x-crossfire bsd\nchemical/x-csml csml csm\nchemical/x-ctx ctx\nchemical/x-cxf cxf cef\nchemical/x-embl-dl-nucleotide emb embl\nchemical/x-galactic-spc spc\nchemical/x-gamess-input inp gam gamin\nchemical/x-gaussian-checkpoint fch fchk\nchemical/x-gaussian-cube cub\nchemical/x-gaussian-input gau gjc gjf\nchemical/x-gaussian-log gal\nchemical/x-gcg8-sequence gcg\nchemical/x-genbank gen\nchemical/x-hin hin\nchemical/x-isostar istr ist\nchemical/x-jcamp-dx jdx dx\nchemical/x-kinemage kin\nchemical/x-macmolecule mcm\nchemical/x-macromodel-input mmd mmod\nchemical/x-mdl-molfile mol\nchemical/x-mdl-rdfile rd\nchemical/x-mdl-rxnfile rxn\nchemical/x-mdl-sdfile sd sdf\nchemical/x-mdl-tgf tgf\nchemical/x-mmcif mcif\nchemical/x-mol2 mol2\nchemical/x-molconn-Z b\nchemical/x-mopac-graph gpt\nchemical/x-mopac-input mop mopcrt mpc zmt\nchemical/x-mopac-out moo\nchemical/x-mopac-vib mvb\nchemical/x-ncbi-asn1 asn\nchemical/x-ncbi-asn1-ascii prt ent\nchemical/x-ncbi-asn1-binary val aso\nchemical/x-ncbi-asn1-spec asn\nchemical/x-pdb pdb ent\nchemical/x-rosdal ros\nchemical/x-swissprot sw\nchemical/x-vamas-iso14976 vms\nchemical/x-vmd vmd\nchemical/x-xtel xtel\nchemical/x-xyz xyz\nimage/gif gif\nimage/ief ief\nimage/jpeg jpeg jpg jpe\nimage/pcx pcx\nimage/png png\nimage/svg+xml svg svgz\nimage/tiff tiff tif\nimage/vnd.djvu djvu djv\nimage/vnd.wap.wbmp wbmp\nimage/x-canon-cr2 cr2\nimage/x-canon-crw crw\nimage/x-cmu-raster ras\nimage/x-coreldraw cdr\nimage/x-coreldrawpattern pat\nimage/x-coreldrawtemplate cdt\nimage/x-corelphotopaint cpt\nimage/x-epson-erf erf\nimage/x-icon ico\nimage/x-jg art\nimage/x-jng jng\nimage/x-ms-bmp bmp\nimage/x-nikon-nef nef\nimage/x-olympus-orf orf\nimage/x-photoshop psd\nimage/x-portable-anymap pnm\nimage/x-portable-bitmap pbm\nimage/x-portable-graymap pgm\nimage/x-portable-pixmap ppm\nimage/x-rgb rgb\nimage/x-xbitmap xbm\nimage/x-xpixmap xpm\nimage/x-xwindowdump xwd\nmessage/rfc822 eml\nmodel/iges igs iges\nmodel/mesh msh mesh silo\nmodel/vrml wrl vrml\nmodel/x3d+vrml x3dv\nmodel/x3d+xml x3d\nmodel/x3d+binary x3db\ntext/cache-manifest manifest\ntext/calendar ics icz\ntext/css css\ntext/csv csv\ntext/h323 323\ntext/html html htm shtml\ntext/iuls uls\ntext/mathml mml\ntext/plain asc txt text pot brf\ntext/richtext rtx\ntext/scriptlet sct wsc\ntext/texmacs tm\ntext/tab-separated-values tsv\ntext/vnd.sun.j2me.app-descriptor jad\ntext/vnd.wap.wml wml\ntext/vnd.wap.wmlscript wmls\ntext/x-bibtex bib\ntext/x-boo boo\ntext/x-c++hdr h++ hpp hxx hh\ntext/x-c++src c++ cpp cxx cc\ntext/x-chdr h\ntext/x-component htc\ntext/x-csh csh\ntext/x-csrc c\ntext/x-dsrc d\ntext/x-diff diff patch\ntext/x-haskell hs\ntext/x-java java\ntext/x-literate-haskell lhs\ntext/x-moc moc\ntext/x-pascal p pas\ntext/x-pcs-gcd gcd\ntext/x-perl pl pm\ntext/x-python py\ntext/x-scala scala\ntext/x-setext etx\ntext/x-sfv sfv\ntext/x-sh sh\ntext/x-tcl tcl tk\ntext/x-tex tex ltx sty cls\ntext/x-vcalendar vcs\ntext/x-vcard vcf\nvideo/3gpp 3gp\nvideo/annodex axv\nvideo/dl dl\nvideo/dv dif dv\nvideo/fli fli\nvideo/gl gl\nvideo/mpeg mpeg mpg mpe\nvideo/MP2T ts\nvideo/mp4 mp4\nvideo/quicktime qt mov\nvideo/ogg ogv\nvideo/webm webm\nvideo/vnd.mpegurl mxu\nvideo/x-flv flv\nvideo/x-la-asf lsf lsx\nvideo/x-mng mng\nvideo/x-ms-asf asf asx\nvideo/x-ms-wm wm\nvideo/x-ms-wmv wmv\nvideo/x-ms-wmx wmx\nvideo/x-ms-wvx wvx\nvideo/x-msvideo avi\nvideo/x-sgi-movie movie\nvideo/x-matroska mpv mkv\nx-conference/x-cooltalk ice\nx-epoc/x-sisx-app sisx\nx-world/x-vrml vrm vrml wrl",b=a.split("\n"),c={};return b.forEach(function(a){var b=a.split(" "),d=b[0],e=b[1].split(" ");e.forEach(function(a){c[a]=d})}),{set:function(a,b){"object"==typeof a?Object.keys(a).forEach(function(b){c[b]=a[b]}):c[a]=b},guess:function(a){return c[a.split(".").pop()]||"aplication/octet-stream"}}}();ZipArchiveReader.prototype.init=function(){{var a,b,c,d,e=this.bytes,f=[],g=[],h=[],i=[],j=e.byteLength-4,k=new DataView(e.buffer,e.byteOffset,e.byteLength),l=this;this.params}if(this.files=h,this.folders=i,this.localFileHeaders=f,this.centralDirHeaders=g,k.getUint32(0,!0)!==zip.LOCAL_FILE_SIGNATURE)throw new Error("zip.unpack: invalid zip file");for(;;){if(k.getUint32(j,!0)===zip.END_SIGNATURE){b=l._getEndCentDirHeader(j);break}if(j--,0===j)throw new Error("zip.unpack: invalid zip file")}for(j=b.startpos,c=0,d=b.direntry;d>c;++c)a=l._getCentralDirHeader(j),g.push(a),j+=a.allsize;for(c=0;d>c;++c)j=g[c].headerpos,a=l._getLocalFileHeader(j),a.crc32=g[c].crc32,a.compsize=g[c].compsize,a.uncompsize=g[c].uncompsize,f.push(a);return this._completeInit()},ZipArchiveReader.prototype._completeInit=function(){var a=this.files,b=this.folders,c=this.params,d=this.localFileHeaders,e=this;return d.forEach(function(c){(47!==c.filename[c.filename.length-1]?a:b).push(c)}),null==c.encoding&&Promise.resolve(d.map(function(a){return a.filename})).then(utils.concatBytes).then(utils.detectEncoding).then(function(a){c.encoding=a}),Promise.all(d.map(function(a){return utils.bytesToString(a.filename,c.encoding).then(function(b){a.filename=b})})).then(function(){return e})},ZipArchiveReader.prototype._getLocalFileHeader=function(a){var b=new DataView(this.buffer,a),c=new Uint8Array(this.buffer,a),d={};return d.signature=b.getUint32(0,!0),d.needver=b.getUint16(4,!0),d.option=b.getUint16(6,!0),d.comptype=b.getUint16(8,!0),d.filetime=b.getUint16(10,!0),d.filedate=b.getUint16(12,!0),d.crc32=b.getUint32(14,!0),d.compsize=b.getUint32(18,!0),d.uncompsize=b.getUint32(22,!0),d.fnamelen=b.getUint16(26,!0),d.extralen=b.getUint16(28,!0),d.headersize=30+d.fnamelen+d.extralen,d.allsize=d.headersize+d.compsize,d.filename=c.subarray(30,30+d.fnamelen),d},ZipArchiveReader.prototype._getCentralDirHeader=function(a){var b=new DataView(this.buffer,a),c={};return c.signature=b.getUint32(0,!0),c.madever=b.getUint16(4,!0),c.needver=b.getUint16(6,!0),c.option=b.getUint16(8,!0),c.comptype=b.getUint16(10,!0),c.filetime=b.getUint16(12,!0),c.filedate=b.getUint16(14,!0),c.crc32=b.getUint32(16,!0),c.compsize=b.getUint32(20,!0),c.uncompsize=b.getUint32(24,!0),c.fnamelen=b.getUint16(28,!0),c.extralen=b.getUint16(30,!0),c.commentlen=b.getUint16(32,!0),c.disknum=b.getUint16(34,!0),c.inattr=b.getUint16(36,!0),c.outattr=b.getUint32(38,!0),c.headerpos=b.getUint32(42,!0),c.allsize=46+c.fnamelen+c.extralen+c.commentlen,c},ZipArchiveReader.prototype._getEndCentDirHeader=function(a){var b=new DataView(this.buffer,a);return{signature:b.getUint32(0,!0),disknum:b.getUint16(4,!0),startdisknum:b.getUint16(6,!0),diskdirentry:b.getUint16(8,!0),direntry:b.getUint16(10,!0),dirsize:b.getUint32(12,!0),startpos:b.getUint32(16,!0),commentlen:b.getUint16(20,!0)}},ZipArchiveReader.prototype.getFileNames=function(){return this.files.map(function(a){return a.filename})},ZipArchiveReader.prototype._getFileIndex=function(a){for(var b=0,c=this.localFileHeaders.length;c>b;++b)if(a===this.localFileHeaders[b].filename)return b;throw new Error("File is not found.")},ZipArchiveReader.prototype._getFileInfo=function(a){var b=this._getFileIndex(a),c=this.centralDirHeaders[b],d=this.localFileHeaders[b];return{offset:c.headerpos+d.headersize,length:d.compsize,isCompressed:d.comptype}},ZipArchiveReader.prototype._decompress=function(a,b){return b?algorithms.inflate(a):a},ZipArchiveReader.prototype._decompressFile=function(a){var b=this._getFileInfo(a);return this._decompress(new Uint8Array(this.buffer,b.offset,b.length),b.isCompressed)},ZipArchiveReader.prototype.readFileAsArrayBuffer=function(a){return new Promise(function(b){b(this._decompressFile(a).buffer)}.bind(this))},ZipArchiveReader.prototype._readFileAs=function(a,b,c){return this.readFileAsBlob(b).then(function(b){return utils.readFileAs.call(null,a,b,c)})},ZipArchiveReader.prototype.readFileAsText=function(a,b){return this._readFileAs("Text",a,b||"UTF-8")},ZipArchiveReader.prototype.readFileAsBinaryString=function(a){return this._readFileAs("BinaryString",a)},ZipArchiveReader.prototype.readFileAsDataURL=function(a){return this._readFileAs("DataURL",a)},ZipArchiveReader.prototype.readFileAsBlob=function(a,b){return new Promise(function(c){c(new Blob([this._decompressFile(a,!1)],{type:b||mimetypes.guess(a)}))}.bind(this))},env.isWorker&&(ZipArchiveReader.prototype.readFileAsArrayBufferSync=function(a){return this._decompressFile(a,!0).buffer},ZipArchiveReader.prototype.readFileAsBlobSync=function(a,b){return new Blob([this._decompressFile(a,!1)],{type:b||mimetypes.guess(a)})},ZipArchiveReader.prototype.readFileAsTextSync=function(a,b){return(new FileReaderSync).readAsText(this.readFileAsBlobSync(a),b||"UTF-8")},ZipArchiveReader.prototype.readFileAsBinaryStringSync=function(a){return(new FileReaderSync).readAsBinaryString(this.readFileAsBlobSync(a))},ZipArchiveReader.prototype.readFileAsDataURLSync=function(a){return(new FileReaderSync).readAsDataURL(this.readFileAsBlobSync(a))},exposeProperty("readFileAsArrayBufferSync",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsArrayBufferSync),exposeProperty("readFileAsBlobSync",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsBlobSync),exposeProperty("readFileAsTextSync",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsTextSync),exposeProperty("readFileAsBinaryStringSync",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsBinaryStringSync),exposeProperty("readFileAsDataURLSync",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsDataURLSync)),exposeProperty("getFileNames",ZipArchiveReader,ZipArchiveReader.prototype.getFileNames),exposeProperty("readFileAsArrayBuffer",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsArrayBuffer),exposeProperty("readFileAsText",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsText),exposeProperty("readFileAsBinaryString",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsBinaryString),exposeProperty("readFileAsDataURL",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsDataURL),exposeProperty("readFileAsBlob",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsBlob),ZipArchiveReaderBlob.prototype=Object.create(ZipArchiveReader.prototype),ZipArchiveReaderBlob.prototype.constructor=ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.init=function(){function a(a,b){return utils.readFileAsArrayBuffer(c.slice(a,b))}var b,c=this.blob,d=(this.params,[]),e=[],f=[],g=[]; -return this.files=f,this.folders=g,this.localFileHeaders=e,this.centralDirHeaders=d,function(){return a(0,4).then(function(a){if(new DataView(a).getUint32(0,!0)===zip.LOCAL_FILE_SIGNATURE)return Math.max(0,c.size-32768);throw new Error("zip.unpack: invalid zip file.")})}().then(function h(b){return a(b,Math.min(c.size,b+32768)).then(function(a){var c,d=new DataView(a);for(c=a.byteLength-4;c--;)if(d.getUint32(c,!0)===zip.END_SIGNATURE)return b+c;if(b)return h(Math.max(b-32768+3,0));throw new Error("zip.unpack: invalid zip file.")})}).then(function(d){return a(d,c.size).then(function(a){return b=ZipArchiveReader.prototype._getEndCentDirHeader.call({buffer:a},0),d})}).then(function(c){return a(b.startpos,c).then(function(a){var c,e,f,g=0,h={buffer:a};for(c=0,e=b.direntry;e>c;++c)f=ZipArchiveReader.prototype._getCentralDirHeader.call(h,g),d.push(f),g+=f.allsize})}).then(function i(b){if(b!==d.length){var c=d[b].headerpos;return a(c+26,c+30).then(function(b){var d=new DataView(b),e=d.getUint16(0,!0),f=d.getUint16(2,!0);return a(c,c+30+e+f)}).then(function(a){var c=ZipArchiveReader.prototype._getLocalFileHeader.call({buffer:a},0);return c.crc32=d[b].crc32,c.compsize=d[b].compsize,c.uncompsize=d[b].uncompsize,e.push(c),i(b+1)})}}.bind(null,0)).then(this._completeInit.bind(this))},ZipArchiveReaderBlob.prototype.readFileAsArrayBuffer=function(a){return this._readFileAs("ArrayBuffer",a)},ZipArchiveReaderBlob.prototype.readFileAsBlob=function(a,b){b=b||mimetypes.guess(a);var c=this._getFileInfo(a),d=this.blob.slice(c.offset,c.offset+c.length,{type:b});return c.isCompressed?utils.readFileAsArrayBuffer(d).then(function(a){return new Blob([algorithms.inflate(new Uint8Array(a))],{type:b})}):Promise.resolve(d)},env.isWorker&&(ZipArchiveReaderBlob.prototype._decompressFile=function(a){var b=this._getFileInfo(a),c=this.blob.slice(b.offset,b.offset+b.length),d=new Uint8Array((new FileReaderSync).readAsArrayBuffer(c));return this._decompress(d,b.isCompressed)},ZipArchiveReaderBlob.prototype.readFileAsArrayBufferSync=function(a){return this._decompressFile(a,!0).buffer},ZipArchiveReaderBlob.prototype.readFileAsBlobSync=function(a,b){return new Blob([this._decompressFile(a,!1)],{type:b||mimetypes.guess(a)})},exposeProperty("readFileAsArrayBufferSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsArrayBufferSync),exposeProperty("readFileAsBlobSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsBlobSync),exposeProperty("readFileAsTextSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsTextSync),exposeProperty("readFileAsBinaryStringSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsBinaryStringSync),exposeProperty("readFileAsDataURLSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsDataURLSync)),exposeProperty("readFileAsArrayBuffer",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsArrayBuffer),exposeProperty("readFileAsText",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsText),exposeProperty("readFileAsBinaryString",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsBinaryString),exposeProperty("readFileAsDataURL",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsDataURL),exposeProperty("readFileAsBlob",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsBlob),exposeProperty("readFileAsTextSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsTextSync),exposeProperty("readFileAsBinaryStringSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsBinaryStringSync),exposeProperty("readFileAsDataURLSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsDataURLSync),zip.unpack=function(){var a=utils.getParams(arguments,["buffer","encoding","chunkSize"]);return new(a.buffer instanceof Blob?ZipArchiveReaderBlob:ZipArchiveReader)(a).init()},expose("jz.zip.unpack",zip.unpack);}).call(this); \ No newline at end of file +function expose(a,b){var c=a.split("."),d=c.pop(),e=global;c.forEach(function(a){e[a]=e[a]||{},e=e[a]}),e[d]=b}function exposeProperty(a,b,c){b.prototype[a]=c}function defun(a,b){return function(){var c,d=arguments[0];return c="[object Object]"===Object.prototype.toString.call(d)?a.map(function(a){return d[a]}):arguments,b.apply(this,c)}}function createLocalFileHeader(a,b,c){var d=new DataView(new ArrayBuffer(30+a.length)),e=new Uint8Array(d.buffer),f=0;return d.setUint32(f,zip.LOCAL_FILE_SIGNATURE,!0),f+=4,d.setUint16(f,20,!0),f+=2,d.setUint16(f,8),f+=2,d.setUint16(f,c?8:0,!0),f+=2,d.setUint16(f,createDosFileTime(b),!0),f+=2,d.setUint16(f,createDosFileDate(b),!0),f+=2,f+=12,d.setUint16(f,a.length,!0),f+=2,f+=2,e.set(a,f),e}function createCentralDirHeader(a,b,c,d,e,f,g){var h=new DataView(new ArrayBuffer(46+a.length)),i=new Uint8Array(h.buffer),j=0;return h.setUint32(j,zip.CENTRAL_DIR_SIGNATURE,!0),j+=4,h.setUint16(j,20,!0),j+=2,h.setUint16(j,20,!0),j+=2,h.setUint16(j,8),j+=2,h.setUint16(j,c?8:0,!0),j+=2,h.setUint16(j,createDosFileTime(b),!0),j+=2,h.setUint16(j,createDosFileDate(b),!0),j+=2,h.setUint32(j,g,!0),j+=4,h.setUint32(j,f,!0),j+=4,h.setUint32(j,e,!0),j+=4,h.setUint16(j,a.length,!0),j+=2,j+=12,h.setUint32(j,d,!0),j+=4,i.set(a,j),i}function createEndCentDirHeader(a,b,c){var d=new DataView(new ArrayBuffer(22));return d.setUint32(0,zip.END_SIGNATURE,!0),d.setUint16(4,0,!0),d.setUint16(6,0,!0),d.setUint16(8,a,!0),d.setUint16(10,a,!0),d.setUint32(12,b,!0),d.setUint32(16,c,!0),d.setUint16(20,0,!0),new Uint8Array(d.buffer)}function createDosFileDate(a){return a.getFullYear()-1980<<9|a.getMonth()+1<<5|a.getDay()}function createDosFileTime(a){return a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function ZipArchiveReader(a){this.bytes=utils.toBytes(a.buffer),this.buffer=this.bytes.buffer,this.params=a}function ZipArchiveReaderBlob(a){this.blob=a.buffer,this.params=a}var utils={},algorithms={},gz={},zip={},env={},zpipe={},stream={algorithms:{},zlib:{},gz:{},zip:{}},global=this;zip.LOCAL_FILE_SIGNATURE=67324752,zip.CENTRAL_DIR_SIGNATURE=33639248,zip.END_SIGNATURE=101010256,env.isWorker="function"==typeof importScripts,expose("jz.algos",algorithms),expose("jz.stream.algos",stream.algorithms),utils.toArray=function(a){return Array.prototype.slice.call(a)},utils.getParams=function(a,b){if("[object Object]"===Object.prototype.toString.call(a[0]))return a[0];var c={};return b.forEach(function(b,d){c[b]=a[d]}),c},utils.toBytes=function(a){switch(Object.prototype.toString.call(a)){case"[object String]":return utils.stringToBytes(a);case"[object Array]":case"[object ArrayBuffer]":return new Uint8Array(a);case"[object Uint8Array]":return a;case"[object Int8Array]":case"[object Uint8ClampedArray]":case"[object CanvasPixelArray]":return new Uint8Array(a.buffer,a.byteOffset,a.byteLength);default:throw new Error("jz.utils.toBytes: not supported type.")}},expose("jz.utils.toBytes",utils.toBytes),utils.readFileAs=function(a,b,c){var d;return d=env.isWorker?function(d){var e=new FileReaderSync;d(e["readAs"+a].call(e,b,c))}:function(d,e){var f=new FileReader;f.onload=function(){d(f.result)},f.onerror=e,f["readAs"+a].call(f,b,c)},new Promise(d)},utils.readFileAsText=function(a,b){return utils.readFileAs("Text",a,b||"UTF-8")},utils.readFileAsArrayBuffer=utils.readFileAs.bind(null,"ArrayBuffer"),utils.readFileAsDataURL=utils.readFileAs.bind(null,"DataURL"),utils.readFileAsBinaryString=utils.readFileAs.bind(null,"BinaryString"),expose("jz.utils.readFileAsArrayBuffer",utils.readFileAsArrayBuffer),expose("jz.utils.readFileAsText",utils.readFileAsText),expose("jz.utils.readFileAsDataURL",utils.readFileAsDataURL),expose("jz.utils.readFileAsBinaryString",utils.readFileAsBinaryString),utils.stringToBytes=function(a){var b,c,d,e=a.length,f=-1,g=32,h=new Uint8Array(g);for(b=0;e>b;++b)c=a.charCodeAt(b),127>=c?h[++f]=c:2047>=c?(h[++f]=192|c>>>6,h[++f]=128|63&c):65535>=c?(h[++f]=224|c>>>12,h[++f]=128|c>>>6&63,h[++f]=128|63&c):(h[++f]=240|c>>>18,h[++f]=128|c>>>12&63,h[++f]=128|c>>>6&63,h[++f]=128|63&c),4>=g-f&&(d=h,g*=2,h=new Uint8Array(g),h.set(d));return h.subarray(0,++f)},utils.bytesToString=function(a,b){return utils.readFileAsText(new Blob([utils.toBytes(a)]),b)},expose("jz.utils.bytesToString",utils.bytesToString),utils.bytesToStringSync=null,env.isWorker&&(utils.bytesToStringSync=function(a,b){return(new FileReaderSync).readAsText(new Blob([utils.toBytes(a)]),b||"UTF-8")},expose("jz.utils.bytesToStringSync",utils.bytesToStringSync)),utils.detectEncoding=function(a){a=utils.toBytes(a);for(var b=0,c=a.length;c>b;++b)if(!(a[b]<128))if(192===(224&a[b])){if(128===(192&a[++b]))continue}else if(224===(240&a[b])){if(128===(192&a[++b])&&128===(192&a[++b]))continue}else{if(240!==(248&a[b]))return"Shift_JIS";if(128===(192&a[++b])&&128===(192&a[++b])&&128===(192&a[++b]))continue}return"UTF-8"},expose("jz.utils.detectEncoding",utils.detectEncoding),Promise.prototype.spread=function(a,b){return Promise.prototype.then.call(this,Function.prototype.apply.bind(a,null),b)},utils.load=function(a){return a=Array.isArray(a)?a:utils.toArray(arguments),Promise.all(a.map(function(a){return new Promise(function(b,c){var d=new XMLHttpRequest;d.open("GET",a),d.responseType="arraybuffer",d.onloadend=function(){var e=d.status;200===e||206===e||0===e?b(new Uint8Array(d.response)):c(new Error("Load Error: "+e+" "+a))},d.onerror=c,d.send()})}))},expose("jz.utils.load",utils.load),utils.concatBytes=function(a){var b,c,d,a=Array.isArray(a)?a:utils.toArray(arguments),e=0,f=0;for(b=0,c=a.length;c>b;++b)e+=a[b].length;for(d=new Uint8Array(e),b=0;c>b;++b)d.set(a[b],f),f+=a[b].length;return d},expose("jz.utils.concatBytes",utils.concatBytes),algorithms.adler32=function(a){for(var b,a=utils.toBytes(a),c=1,d=0,e=0,f=65521,g=a.length;g>0;){b=g>5550?5550:g,g-=b;do c+=a[e++],d+=c;while(--b);c%=f,d%=f}return(d<<16|c)>>>0},expose("jz.algorithms.adler32",algorithms.adler32),algorithms.crc32=function(){var a=function(){var a,b,c,d=3988292384,e=new Uint32Array(256);for(b=0;256>b;++b){for(a=b,c=0;8>c;++c)a=1&a?a>>>1^d:a>>>1;e[b]=a>>>0}return e}();return defun(["buffer","crc"],function(b,c){for(var d=utils.toBytes(b),c=null==c?4294967295:~c>>>0,e=0,f=d.length,g=a;f>e;++e)c=c>>>8^g[d[e]^255&c];return~c>>>0})}(),expose("jz.algorithms.crc32",algorithms.crc32),algorithms.deflate=defun(["buffer","level","chunkSize"],function(a,b,c){return zlib.rawDeflate(utils.toBytes(a),b,c)}),expose("jz.algorithms.deflate",algorithms.deflate),algorithms.inflate=defun(["buffer","chunkSize"],function(a,b){return zlib.rawInflate(utils.toBytes(a),b)}),expose("jz.algorithms.inflate",algorithms.inflate);var ZipArchiveWriter=defun(["shareMemory","chunkSize"],function(a,b){this.shareMemory=a,this.chunkSize=b,this.dirs={},this.centralDirHeaders=[],this.offset=0,this.date=new Date,this.listners={}});ZipArchiveWriter.prototype.write=function(a,b,c){var d=this;return a.split("/").reduce(function(a,b){return d.writeDir(a+"/"),a+"/"+b}),this.writeFile(a,b,c),this},ZipArchiveWriter.prototype.writeDir=function(a){var b;return a+=/.+\/$/.test(a)?"":"/",this.dirs[a]||(this.dirs[a]=!0,a=utils.toBytes(a),b=createLocalFileHeader(a,this.date,!1),this.centralDirHeaders.push(createCentralDirHeader(a,this.date,!1,this.offset,0,0,0)),this.trigger("data",b),this.offset+=b.length),this},ZipArchiveWriter.prototype.writeFile=function(a,b,c){a=utils.toBytes(a);var d=this.offset,e=createLocalFileHeader(a,this.date,c),f=0,g=this;return this.trigger("data",e),c?stream.algorithms.deflate({buffer:b,level:c,streamFn:function(a){f+=a.length,g.trigger("data",a)},shareMemory:this.shareMemory,chunkSize:this.chunkSize}):(f=b.length,this.trigger("data",b)),this.centralDirHeaders.push(createCentralDirHeader(a,this.date,c,d,b.length,f,algorithms.crc32(b))),this.offset+=e.length+f,this},ZipArchiveWriter.prototype.writeEnd=function(){var a=0,b=this;this.centralDirHeaders.forEach(function(c){a+=c.length,b.trigger("data",c)}),this.trigger("data",createEndCentDirHeader(this.centralDirHeaders.length,a,this.offset)),this.trigger("end",null)},ZipArchiveWriter.prototype.on=function(a,b){return this.listners[a]||(this.listners[a]=[]),this.listners[a].push(b),this},ZipArchiveWriter.prototype.trigger=function(a,b){this.listners[a]&&this.listners[a].forEach(function(a){a(b)})},expose("jz.zip.ZipArchiveWriter",ZipArchiveWriter),exposeProperty("write",ZipArchiveWriter,ZipArchiveWriter.prototype.write),exposeProperty("writeDir",ZipArchiveWriter,ZipArchiveWriter.prototype.writeDir),exposeProperty("writeFile",ZipArchiveWriter,ZipArchiveWriter.prototype.writeFile),exposeProperty("writeEnd",ZipArchiveWriter,ZipArchiveWriter.prototype.writeEnd),exposeProperty("on",ZipArchiveWriter,ZipArchiveWriter.prototype.on),stream.algorithms.deflate=defun(["buffer","streamFn","level","shareMemory","chunkSize"],function(a,b,c,d,e){zlib.stream.rawDeflate({input:utils.toBytes(a),streamFn:b,level:c,shareMemory:d,chunkSize:e})}),expose("jz.stream.algorithms.deflate",stream.algorithms.deflate),stream.algorithms.inflate=defun(["buffer","streamFn","shareMemory","chunkSize"],function(a,b,c,d){zlib.stream.rawInflate({input:utils.toBytes(a),streamFn:b,shareMemory:c,chunkSize:d})}),expose("jz.stream.algorithms.inflate",stream.algorithms.inflate),stream.zlib.compress=defun(["buffer","streamFn","level","shareMemory","chunkSize"],function(a,b,c,d,e){zlib.stream.deflate({input:utils.toBytes(a),streamFn:b,level:c,shareMemory:d,chunkSize:e})}),expose("jz.stream.zlib.compress",stream.zlib.compress),stream.zlib.decompress=defun(["buffer","streamFn","shareMemory","chunkSize"],function(a,b,c,d){zlib.stream.inflate({input:a,streamFn:b,shareMemory:c,chunkSize:d})}),expose("jz.stream.zlib.decompress",stream.zlib.decompress),stream.gz.compress=defun(["buffer","streamFn","level","shareMemory","chunkSize","fname","fcomment"],function(a,b,c,d,e,f,g){var h,i,j,k=utils.toBytes(a),f=f&&utils.toBytes(f),g=g&&utils.toBytes(g),l=0,m=10,n=0,o=Date.now();f&&(m+=f.length+1,l|=8),g&&(m+=g.length+1,l|=16),h=new Uint8Array(m),j=new DataView(h.buffer),j.setUint32(n,529205248|l),n+=4,j.setUint32(n,o,!0),n+=4,j.setUint16(n,1279),n+=2,f&&(h.set(f,n),n+=f.length,h[n++]=0),g&&(h.set(g,n),n+=g.length,h[n++]=0),b(h),stream.algorithms.deflate({buffer:k,streamFn:b,shareMemory:d,chunkSize:e}),i=new Uint8Array(8),j=new DataView(i.buffer),j.setUint32(0,algorithms.crc32(k),!0),j.setUint32(4,k.length,!0),b(i)}),expose("jz.stream.gz.compress",stream.gz.compress),stream.gz.decompress=defun(["buffer","streamFn","shareMemory","chunkSize"],function(a,b,c,d){var e,f,g=utils.toBytes(a),h=10,i=new DataView(g.buffer,g.byteOffset,g.byteLength);if(8075!==i.getUint16(0))throw new Error("jz.gz.decompress: invalid gzip file.");if(8!==g[2])throw new Error("jz.gz.decompress: not deflate.");if(e=g[3],4&e&&(h+=i.getUint16(h,!0)+2),8&e)for(;g[h++];);if(16&e)for(;g[h++];);if(2&e&&(h+=2),stream.algorithms.inflate({buffer:g.subarray(h,g.length-8),streamFn:function(a){f=algorithms.crc32(a,f),b(a)},shareMemory:c,chunkSize:d}),f!==i.getUint32(g.length-8,!0))throw new Error("js.stream.gz.decompress: file is broken.")}),expose("jz.stream.gz.decompress",stream.gz.decompress),stream.zip.pack=defun(["files","streamFn","level","shareMemory","chunkSize"],function(a,b,c,d,e){function f(a,b,c){var d,e=c.children||c.dir||c.folder;if(a="number"==typeof c.level?c.level:a,e)b+=c.name+(/.+\/$/.test(c.name)?"":"/"),i.writeDir(b),e.forEach(f.bind(null,a,b));else{if(null!=c.buffer&&(d=c.buffer),null!=c.str&&(d=c.str),null==d)throw new Error("jz.zip.pack: This type is not supported.");b+=c.name,i.writeFile(b,utils.toBytes(d),a)}}function g(a){var b=a.children||a.dir||a.folder;b?b.forEach(g):a.url&&h.push(utils.load(a.url).then(function(b){a.buffer=b[0],a.url=null}))}var h=[],i=new ZipArchiveWriter(d,e);return i.on("data",b),a.forEach(g),Promise.all(h).then(function(){a.forEach(f.bind(null,c,"")),i.writeEnd()})}),expose("jz.stream.zip.pack",stream.zip.pack),expose("jz.zlib.compress",defun(["buffer","level","chunkSize"],function(a,b,c){return zlib.deflate(utils.toBytes(a),b,c)})),expose("jz.zlib.decompress",defun(["buffer","chunkSize"],function(a,b){return zlib.inflate(utils.toBytes(a),b)})),gz.compress=defun(["buffer","level","chunkSize","fname","fcomment"],function(a,b,c,d,e){var f=[];return stream.gz.compress({buffer:a,level:b,chunkSize:c,fname:d,fcomment:e,streamFn:function(a){f.push(a)}}),utils.concatBytes(f)}),expose("jz.gz.compress",gz.compress),gz.decompress=defun(["buffer","chunkSize"],function(a,b){var c=[];return stream.gz.decompress({buffer:a,streamFn:function(a){c.push(a)},chunkSize:b}),utils.concatBytes(c)}),expose("jz.gz.decompress",gz.decompress),zip.pack=defun(["files","level","chunkSize"],function(a,b,c){var d=[];return stream.zip.pack({files:a,shareMemory:!1,level:b,chunkSize:c,streamFn:function(a){d.push(a)}}).then(function(){return utils.concatBytes(d)})}),expose("jz.zip.pack",zip.pack);var mimetypes=function(){var a="application/epub+zip epub\napplication/x-gzip gz\napplication/andrew-inset ez\napplication/annodex anx\napplication/atom+xml atom\napplication/atomcat+xml atomcat\napplication/atomserv+xml atomsrv\napplication/bbolin lin\napplication/cap cap pcap\napplication/cu-seeme cu\napplication/davmount+xml davmount\napplication/dsptype tsp\napplication/ecmascript es\napplication/futuresplash spl\napplication/hta hta\napplication/java-archive jar\napplication/java-serialized-object ser\napplication/java-vm class\napplication/javascript js\napplication/json json\napplication/m3g m3g\napplication/mac-binhex40 hqx\napplication/mac-compactpro cpt\napplication/mathematica nb nbp\napplication/msaccess mdb\napplication/msword doc dot\napplication/mxf mxf\napplication/octet-stream bin\napplication/oda oda\napplication/ogg ogx\napplication/onenote one onetoc2 onetmp onepkg\napplication/pdf pdf\napplication/pgp-keys key\napplication/pgp-signature pgp\napplication/pics-rules prf\napplication/postscript ps ai eps epsi epsf eps2 eps3\napplication/rar rar\napplication/rdf+xml rdf\napplication/rss+xml rss\napplication/rtf rtf\napplication/sla stl\napplication/smil smi smil\napplication/xhtml+xml xhtml xht\napplication/xml xml xsl xsd\napplication/xspf+xml xspf\napplication/zip zip\napplication/vnd.android.package-archive apk\napplication/vnd.cinderella cdy\napplication/vnd.google-earth.kml+xml kml\napplication/vnd.google-earth.kmz kmz\napplication/vnd.mozilla.xul+xml xul\napplication/vnd.ms-excel xls xlb xlt\napplication/vnd.ms-excel.addin.macroEnabled.12 xlam\napplication/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb\napplication/vnd.ms-excel.sheet.macroEnabled.12 xlsm\napplication/vnd.ms-excel.template.macroEnabled.12 xltm\napplication/vnd.ms-officetheme thmx\napplication/vnd.ms-pki.seccat cat\napplication/vnd.ms-powerpoint ppt pps\napplication/vnd.ms-powerpoint.addin.macroEnabled.12 ppam\napplication/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm\napplication/vnd.ms-powerpoint.slide.macroEnabled.12 sldm\napplication/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm\napplication/vnd.ms-powerpoint.template.macroEnabled.12 potm\napplication/vnd.ms-word.document.macroEnabled.12 docm\napplication/vnd.ms-word.template.macroEnabled.12 dotm\napplication/vnd.oasis.opendocument.chart odc\napplication/vnd.oasis.opendocument.database odb\napplication/vnd.oasis.opendocument.formula odf\napplication/vnd.oasis.opendocument.graphics odg\napplication/vnd.oasis.opendocument.graphics-template otg\napplication/vnd.oasis.opendocument.image odi\napplication/vnd.oasis.opendocument.presentation odp\napplication/vnd.oasis.opendocument.presentation-template otp\napplication/vnd.oasis.opendocument.spreadsheet ods\napplication/vnd.oasis.opendocument.spreadsheet-template ots\napplication/vnd.oasis.opendocument.text odt\napplication/vnd.oasis.opendocument.text-master odm\napplication/vnd.oasis.opendocument.text-template ott\napplication/vnd.oasis.opendocument.text-web oth\napplication/vnd.openxmlformats-officedocument.presentationml.presentation pptx\napplication/vnd.openxmlformats-officedocument.presentationml.slide sldx\napplication/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx\napplication/vnd.openxmlformats-officedocument.presentationml.template potx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.template xltx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.template xltx\napplication/vnd.openxmlformats-officedocument.wordprocessingml.document docx\napplication/vnd.openxmlformats-officedocument.wordprocessingml.template dotx\napplication/vnd.rim.cod cod\napplication/vnd.smaf mmf\napplication/vnd.stardivision.calc sdc\napplication/vnd.stardivision.chart sds\napplication/vnd.stardivision.draw sda\napplication/vnd.stardivision.impress sdd\napplication/vnd.stardivision.math sdf\napplication/vnd.stardivision.writer sdw\napplication/vnd.stardivision.writer-global sgl\napplication/vnd.sun.xml.calc sxc\napplication/vnd.sun.xml.calc.template stc\napplication/vnd.sun.xml.draw sxd\napplication/vnd.sun.xml.draw.template std\napplication/vnd.sun.xml.impress sxi\napplication/vnd.sun.xml.impress.template sti\napplication/vnd.sun.xml.math sxm\napplication/vnd.sun.xml.writer sxw\napplication/vnd.sun.xml.writer.global sxg\napplication/vnd.sun.xml.writer.template stw\napplication/vnd.symbian.install sis\napplication/vnd.visio vsd\napplication/vnd.wap.wbxml wbxml\napplication/vnd.wap.wmlc wmlc\napplication/vnd.wap.wmlscriptc wmlsc\napplication/vnd.wordperfect wpd\napplication/vnd.wordperfect5.1 wp5\napplication/x-123 wk\napplication/x-7z-compressed 7z\napplication/x-abiword abw\napplication/x-apple-diskimage dmg\napplication/x-bcpio bcpio\napplication/x-bittorrent torrent\napplication/x-cab cab\napplication/x-cbr cbr\napplication/x-cbz cbz\napplication/x-cdf cdf cda\napplication/x-cdlink vcd\napplication/x-chess-pgn pgn\napplication/x-comsol mph\napplication/x-cpio cpio\napplication/x-csh csh\napplication/x-debian-package deb udeb\napplication/x-director dcr dir dxr\napplication/x-dms dms\napplication/x-doom wad\napplication/x-dvi dvi\napplication/x-font pfa pfb gsf pcf pcf.Z\napplication/x-freemind mm\napplication/x-futuresplash spl\napplication/x-ganttproject gan\napplication/x-gnumeric gnumeric\napplication/x-go-sgf sgf\napplication/x-graphing-calculator gcf\napplication/x-gtar gtar\napplication/x-gtar-compressed tgz taz\napplication/x-hdf hdf\napplication/x-httpd-eruby rhtml\napplication/x-httpd-php phtml pht php\napplication/x-httpd-php-source phps\napplication/x-httpd-php3 php3\napplication/x-httpd-php3-preprocessed php3p\napplication/x-httpd-php4 php4\napplication/x-httpd-php5 php5\napplication/x-ica ica\napplication/x-info info\napplication/x-internet-signup ins isp\napplication/x-iphone iii\napplication/x-iso9660-image iso\napplication/x-jam jam\napplication/x-java-jnlp-file jnlp\napplication/x-jmol jmz\napplication/x-kchart chrt\napplication/x-killustrator kil\napplication/x-koan skp skd skt skm\napplication/x-kpresenter kpr kpt\napplication/x-kspread ksp\napplication/x-kword kwd kwt\napplication/x-latex latex\napplication/x-lha lha\napplication/x-lyx lyx\napplication/x-lzh lzh\napplication/x-lzx lzx\napplication/x-maker frm maker frame fm fb book fbdoc\napplication/x-mif mif\napplication/x-mpegURL m3u8\napplication/x-ms-wmd wmd\napplication/x-ms-wmz wmz\napplication/x-msdos-program com exe bat dll\napplication/x-msi msi\napplication/x-netcdf nc\napplication/x-ns-proxy-autoconfig pac dat\napplication/x-nwc nwc\napplication/x-object o\napplication/x-oz-application oza\napplication/x-pkcs7-certreqresp p7r\napplication/x-pkcs7-crl crl\napplication/x-python-code pyc pyo\napplication/x-qgis qgs shp shx\napplication/x-quicktimeplayer qtl\napplication/x-rdp rdp\napplication/x-redhat-package-manager rpm\napplication/x-ruby rb\napplication/x-scilab sci sce\napplication/x-sh sh\napplication/x-shar shar\napplication/x-shockwave-flash swf swfl\napplication/x-silverlight scr\napplication/x-sql sql\napplication/x-stuffit sit sitx\napplication/x-sv4cpio sv4cpio\napplication/x-sv4crc sv4crc\napplication/x-tar tar\napplication/x-tcl tcl\napplication/x-tex-gf gf\napplication/x-tex-pk pk\napplication/x-texinfo texinfo texi\napplication/x-trash ~ % bak old sik\napplication/x-troff t tr roff\napplication/x-troff-man man\napplication/x-troff-me me\napplication/x-troff-ms ms\napplication/x-ustar ustar\napplication/x-wais-source src\napplication/x-wingz wz\napplication/x-x509-ca-cert crt\napplication/x-xcf xcf\napplication/x-xfig fig\napplication/x-xpinstall xpi\naudio/amr amr\naudio/amr-wb awb\naudio/amr amr\naudio/amr-wb awb\naudio/annodex axa\naudio/basic au snd\naudio/csound csd orc sco\naudio/flac flac\naudio/midi mid midi kar\naudio/mpeg mpga mpega mp2 mp3 m4a\naudio/mpegurl m3u\naudio/ogg oga ogg spx\naudio/prs.sid sid\naudio/x-aiff aif aiff aifc\naudio/x-gsm gsm\naudio/x-mpegurl m3u\naudio/x-ms-wma wma\naudio/x-ms-wax wax\naudio/x-pn-realaudio ra rm ram\naudio/x-realaudio ra\naudio/x-scpls pls\naudio/x-sd2 sd2\naudio/x-wav wav\nchemical/x-alchemy alc\nchemical/x-cache cac cache\nchemical/x-cache-csf csf\nchemical/x-cactvs-binary cbin cascii ctab\nchemical/x-cdx cdx\nchemical/x-cerius cer\nchemical/x-chem3d c3d\nchemical/x-chemdraw chm\nchemical/x-cif cif\nchemical/x-cmdf cmdf\nchemical/x-cml cml\nchemical/x-compass cpa\nchemical/x-crossfire bsd\nchemical/x-csml csml csm\nchemical/x-ctx ctx\nchemical/x-cxf cxf cef\nchemical/x-embl-dl-nucleotide emb embl\nchemical/x-galactic-spc spc\nchemical/x-gamess-input inp gam gamin\nchemical/x-gaussian-checkpoint fch fchk\nchemical/x-gaussian-cube cub\nchemical/x-gaussian-input gau gjc gjf\nchemical/x-gaussian-log gal\nchemical/x-gcg8-sequence gcg\nchemical/x-genbank gen\nchemical/x-hin hin\nchemical/x-isostar istr ist\nchemical/x-jcamp-dx jdx dx\nchemical/x-kinemage kin\nchemical/x-macmolecule mcm\nchemical/x-macromodel-input mmd mmod\nchemical/x-mdl-molfile mol\nchemical/x-mdl-rdfile rd\nchemical/x-mdl-rxnfile rxn\nchemical/x-mdl-sdfile sd sdf\nchemical/x-mdl-tgf tgf\nchemical/x-mmcif mcif\nchemical/x-mol2 mol2\nchemical/x-molconn-Z b\nchemical/x-mopac-graph gpt\nchemical/x-mopac-input mop mopcrt mpc zmt\nchemical/x-mopac-out moo\nchemical/x-mopac-vib mvb\nchemical/x-ncbi-asn1 asn\nchemical/x-ncbi-asn1-ascii prt ent\nchemical/x-ncbi-asn1-binary val aso\nchemical/x-ncbi-asn1-spec asn\nchemical/x-pdb pdb ent\nchemical/x-rosdal ros\nchemical/x-swissprot sw\nchemical/x-vamas-iso14976 vms\nchemical/x-vmd vmd\nchemical/x-xtel xtel\nchemical/x-xyz xyz\nimage/gif gif\nimage/ief ief\nimage/jpeg jpeg jpg jpe\nimage/pcx pcx\nimage/png png\nimage/svg+xml svg svgz\nimage/tiff tiff tif\nimage/vnd.djvu djvu djv\nimage/vnd.wap.wbmp wbmp\nimage/x-canon-cr2 cr2\nimage/x-canon-crw crw\nimage/x-cmu-raster ras\nimage/x-coreldraw cdr\nimage/x-coreldrawpattern pat\nimage/x-coreldrawtemplate cdt\nimage/x-corelphotopaint cpt\nimage/x-epson-erf erf\nimage/x-icon ico\nimage/x-jg art\nimage/x-jng jng\nimage/x-ms-bmp bmp\nimage/x-nikon-nef nef\nimage/x-olympus-orf orf\nimage/x-photoshop psd\nimage/x-portable-anymap pnm\nimage/x-portable-bitmap pbm\nimage/x-portable-graymap pgm\nimage/x-portable-pixmap ppm\nimage/x-rgb rgb\nimage/x-xbitmap xbm\nimage/x-xpixmap xpm\nimage/x-xwindowdump xwd\nmessage/rfc822 eml\nmodel/iges igs iges\nmodel/mesh msh mesh silo\nmodel/vrml wrl vrml\nmodel/x3d+vrml x3dv\nmodel/x3d+xml x3d\nmodel/x3d+binary x3db\ntext/cache-manifest manifest\ntext/calendar ics icz\ntext/css css\ntext/csv csv\ntext/h323 323\ntext/html html htm shtml\ntext/iuls uls\ntext/mathml mml\ntext/plain asc txt text pot brf\ntext/richtext rtx\ntext/scriptlet sct wsc\ntext/texmacs tm\ntext/tab-separated-values tsv\ntext/vnd.sun.j2me.app-descriptor jad\ntext/vnd.wap.wml wml\ntext/vnd.wap.wmlscript wmls\ntext/x-bibtex bib\ntext/x-boo boo\ntext/x-c++hdr h++ hpp hxx hh\ntext/x-c++src c++ cpp cxx cc\ntext/x-chdr h\ntext/x-component htc\ntext/x-csh csh\ntext/x-csrc c\ntext/x-dsrc d\ntext/x-diff diff patch\ntext/x-haskell hs\ntext/x-java java\ntext/x-literate-haskell lhs\ntext/x-moc moc\ntext/x-pascal p pas\ntext/x-pcs-gcd gcd\ntext/x-perl pl pm\ntext/x-python py\ntext/x-scala scala\ntext/x-setext etx\ntext/x-sfv sfv\ntext/x-sh sh\ntext/x-tcl tcl tk\ntext/x-tex tex ltx sty cls\ntext/x-vcalendar vcs\ntext/x-vcard vcf\nvideo/3gpp 3gp\nvideo/annodex axv\nvideo/dl dl\nvideo/dv dif dv\nvideo/fli fli\nvideo/gl gl\nvideo/mpeg mpeg mpg mpe\nvideo/MP2T ts\nvideo/mp4 mp4\nvideo/quicktime qt mov\nvideo/ogg ogv\nvideo/webm webm\nvideo/vnd.mpegurl mxu\nvideo/x-flv flv\nvideo/x-la-asf lsf lsx\nvideo/x-mng mng\nvideo/x-ms-asf asf asx\nvideo/x-ms-wm wm\nvideo/x-ms-wmv wmv\nvideo/x-ms-wmx wmx\nvideo/x-ms-wvx wvx\nvideo/x-msvideo avi\nvideo/x-sgi-movie movie\nvideo/x-matroska mpv mkv\nx-conference/x-cooltalk ice\nx-epoc/x-sisx-app sisx\nx-world/x-vrml vrm vrml wrl",b=a.split("\n"),c={};return b.forEach(function(a){var b=a.split(" "),d=b[0],e=b[1].split(" ");e.forEach(function(a){c[a]=d})}),{set:function(a,b){"object"==typeof a?Object.keys(a).forEach(function(b){c[b]=a[b]}):c[a]=b},guess:function(a){return c[a.split(".").pop()]||"aplication/octet-stream"}}}();ZipArchiveReader.prototype.init=function(){{var a,b,c,d,e=this.bytes,f=[],g=[],h=[],i=[],j=e.byteLength-4,k=new DataView(e.buffer,e.byteOffset,e.byteLength),l=this;this.params}if(this.files=h,this.folders=i,this.localFileHeaders=f,this.centralDirHeaders=g,k.getUint32(0,!0)!==zip.LOCAL_FILE_SIGNATURE)throw new Error("zip.unpack: invalid zip file");for(;;){if(k.getUint32(j,!0)===zip.END_SIGNATURE){b=l._getEndCentDirHeader(j);break}if(j--,0===j)throw new Error("zip.unpack: invalid zip file")}for(j=b.startpos,c=0,d=b.direntry;d>c;++c)a=l._getCentralDirHeader(j),g.push(a),j+=a.allsize;for(c=0;d>c;++c)j=g[c].headerpos,a=l._getLocalFileHeader(j),a.crc32=g[c].crc32,a.compsize=g[c].compsize,a.uncompsize=g[c].uncompsize,f.push(a);return this._completeInit()},ZipArchiveReader.prototype._completeInit=function(){var a=this.files,b=this.folders,c=this.params,d=this.localFileHeaders,e=this;return d.forEach(function(c){(47!==c.filename[c.filename.length-1]?a:b).push(c)}),null==c.encoding&&Promise.resolve(d.map(function(a){return a.filename})).then(utils.concatBytes).then(utils.detectEncoding).then(function(a){c.encoding=a}),Promise.all(d.map(function(a){return utils.bytesToString(a.filename,c.encoding).then(function(b){a.filename=b})})).then(function(){return e})},ZipArchiveReader.prototype._getLocalFileHeader=function(a){var b=new DataView(this.buffer,a),c=new Uint8Array(this.buffer,a),d={};return d.signature=b.getUint32(0,!0),d.needver=b.getUint16(4,!0),d.option=b.getUint16(6,!0),d.comptype=b.getUint16(8,!0),d.filetime=b.getUint16(10,!0),d.filedate=b.getUint16(12,!0),d.crc32=b.getUint32(14,!0),d.compsize=b.getUint32(18,!0),d.uncompsize=b.getUint32(22,!0),d.fnamelen=b.getUint16(26,!0),d.extralen=b.getUint16(28,!0),d.headersize=30+d.fnamelen+d.extralen,d.allsize=d.headersize+d.compsize,d.filename=c.subarray(30,30+d.fnamelen),d},ZipArchiveReader.prototype._getCentralDirHeader=function(a){var b=new DataView(this.buffer,a),c={};return c.signature=b.getUint32(0,!0),c.madever=b.getUint16(4,!0),c.needver=b.getUint16(6,!0),c.option=b.getUint16(8,!0),c.comptype=b.getUint16(10,!0),c.filetime=b.getUint16(12,!0),c.filedate=b.getUint16(14,!0),c.crc32=b.getUint32(16,!0),c.compsize=b.getUint32(20,!0),c.uncompsize=b.getUint32(24,!0),c.fnamelen=b.getUint16(28,!0),c.extralen=b.getUint16(30,!0),c.commentlen=b.getUint16(32,!0),c.disknum=b.getUint16(34,!0),c.inattr=b.getUint16(36,!0),c.outattr=b.getUint32(38,!0),c.headerpos=b.getUint32(42,!0),c.allsize=46+c.fnamelen+c.extralen+c.commentlen,c},ZipArchiveReader.prototype._getEndCentDirHeader=function(a){var b=new DataView(this.buffer,a);return{signature:b.getUint32(0,!0),disknum:b.getUint16(4,!0),startdisknum:b.getUint16(6,!0),diskdirentry:b.getUint16(8,!0),direntry:b.getUint16(10,!0),dirsize:b.getUint32(12,!0),startpos:b.getUint32(16,!0),commentlen:b.getUint16(20,!0)}},ZipArchiveReader.prototype.getFileNames=function(){return this.files.map(function(a){return a.filename})},ZipArchiveReader.prototype._getFileIndex=function(a){for(var b=0,c=this.localFileHeaders.length;c>b;++b)if(a===this.localFileHeaders[b].filename)return b;throw new Error("File is not found.")},ZipArchiveReader.prototype._getFileInfo=function(a){var b=this._getFileIndex(a),c=this.centralDirHeaders[b],d=this.localFileHeaders[b];return{offset:c.headerpos+d.headersize,length:d.compsize,isCompressed:d.comptype}},ZipArchiveReader.prototype._decompress=function(a,b){return b?algorithms.inflate(a):a},ZipArchiveReader.prototype._decompressFile=function(a){var b=this._getFileInfo(a);return this._decompress(new Uint8Array(this.buffer,b.offset,b.length),b.isCompressed)},ZipArchiveReader.prototype.readFileAsArrayBuffer=function(a){return new Promise(function(b){b(this._decompressFile(a).buffer)}.bind(this))},ZipArchiveReader.prototype._readFileAs=function(a,b,c){return this.readFileAsBlob(b).then(function(b){return utils.readFileAs.call(null,a,b,c)})},ZipArchiveReader.prototype.readFileAsText=function(a,b){return this._readFileAs("Text",a,b||"UTF-8")},ZipArchiveReader.prototype.readFileAsBinaryString=function(a){return this._readFileAs("BinaryString",a)},ZipArchiveReader.prototype.readFileAsDataURL=function(a){return this._readFileAs("DataURL",a)},ZipArchiveReader.prototype.readFileAsBlob=function(a,b){return new Promise(function(c){c(new Blob([this._decompressFile(a,!1)],{type:b||mimetypes.guess(a)}))}.bind(this))},env.isWorker&&(ZipArchiveReader.prototype.readFileAsArrayBufferSync=function(a){return this._decompressFile(a,!0).buffer},ZipArchiveReader.prototype.readFileAsBlobSync=function(a,b){return new Blob([this._decompressFile(a,!1)],{type:b||mimetypes.guess(a)})},ZipArchiveReader.prototype.readFileAsTextSync=function(a,b){return(new FileReaderSync).readAsText(this.readFileAsBlobSync(a),b||"UTF-8")},ZipArchiveReader.prototype.readFileAsBinaryStringSync=function(a){return(new FileReaderSync).readAsBinaryString(this.readFileAsBlobSync(a))},ZipArchiveReader.prototype.readFileAsDataURLSync=function(a){return(new FileReaderSync).readAsDataURL(this.readFileAsBlobSync(a))},exposeProperty("readFileAsArrayBufferSync",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsArrayBufferSync),exposeProperty("readFileAsBlobSync",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsBlobSync),exposeProperty("readFileAsTextSync",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsTextSync),exposeProperty("readFileAsBinaryStringSync",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsBinaryStringSync),exposeProperty("readFileAsDataURLSync",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsDataURLSync)),exposeProperty("getFileNames",ZipArchiveReader,ZipArchiveReader.prototype.getFileNames),exposeProperty("readFileAsArrayBuffer",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsArrayBuffer),exposeProperty("readFileAsText",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsText),exposeProperty("readFileAsBinaryString",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsBinaryString),exposeProperty("readFileAsDataURL",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsDataURL),exposeProperty("readFileAsBlob",ZipArchiveReader,ZipArchiveReader.prototype.readFileAsBlob),ZipArchiveReaderBlob.prototype=Object.create(ZipArchiveReader.prototype),ZipArchiveReaderBlob.prototype.constructor=ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.init=function(){function a(a,b){return utils.readFileAsArrayBuffer(c.slice(a,b))}var b,c=this.blob,d=(this.params,[]),e=[],f=[],g=[];return this.files=f,this.folders=g,this.localFileHeaders=e,this.centralDirHeaders=d,function(){return a(0,4).then(function(a){if(new DataView(a).getUint32(0,!0)===zip.LOCAL_FILE_SIGNATURE)return Math.max(0,c.size-32768);throw new Error("zip.unpack: invalid zip file.")})}().then(function h(b){return a(b,Math.min(c.size,b+32768)).then(function(a){var c,d=new DataView(a); +for(c=a.byteLength-4;c--;)if(d.getUint32(c,!0)===zip.END_SIGNATURE)return b+c;if(b)return h(Math.max(b-32768+3,0));throw new Error("zip.unpack: invalid zip file.")})}).then(function(d){return a(d,c.size).then(function(a){return b=ZipArchiveReader.prototype._getEndCentDirHeader.call({buffer:a},0),d})}).then(function(c){return a(b.startpos,c).then(function(a){var c,e,f,g=0,h={buffer:a};for(c=0,e=b.direntry;e>c;++c)f=ZipArchiveReader.prototype._getCentralDirHeader.call(h,g),d.push(f),g+=f.allsize})}).then(function i(b){if(b!==d.length){var c=d[b].headerpos;return a(c+26,c+30).then(function(b){var d=new DataView(b),e=d.getUint16(0,!0),f=d.getUint16(2,!0);return a(c,c+30+e+f)}).then(function(a){var c=ZipArchiveReader.prototype._getLocalFileHeader.call({buffer:a},0);return c.crc32=d[b].crc32,c.compsize=d[b].compsize,c.uncompsize=d[b].uncompsize,e.push(c),i(b+1)})}}.bind(null,0)).then(this._completeInit.bind(this))},ZipArchiveReaderBlob.prototype.readFileAsArrayBuffer=function(a){return this._readFileAs("ArrayBuffer",a)},ZipArchiveReaderBlob.prototype.readFileAsBlob=function(a,b){b=b||mimetypes.guess(a);var c=this._getFileInfo(a),d=this.blob.slice(c.offset,c.offset+c.length,{type:b});return c.isCompressed?utils.readFileAsArrayBuffer(d).then(function(a){return new Blob([algorithms.inflate(new Uint8Array(a))],{type:b})}):Promise.resolve(d)},env.isWorker&&(ZipArchiveReaderBlob.prototype._decompressFile=function(a){var b=this._getFileInfo(a),c=this.blob.slice(b.offset,b.offset+b.length),d=new Uint8Array((new FileReaderSync).readAsArrayBuffer(c));return this._decompress(d,b.isCompressed)},ZipArchiveReaderBlob.prototype.readFileAsArrayBufferSync=function(a){return this._decompressFile(a,!0).buffer},ZipArchiveReaderBlob.prototype.readFileAsBlobSync=function(a,b){return new Blob([this._decompressFile(a,!1)],{type:b||mimetypes.guess(a)})},exposeProperty("readFileAsArrayBufferSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsArrayBufferSync),exposeProperty("readFileAsBlobSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsBlobSync),exposeProperty("readFileAsTextSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsTextSync),exposeProperty("readFileAsBinaryStringSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsBinaryStringSync),exposeProperty("readFileAsDataURLSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsDataURLSync)),exposeProperty("readFileAsArrayBuffer",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsArrayBuffer),exposeProperty("readFileAsText",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsText),exposeProperty("readFileAsBinaryString",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsBinaryString),exposeProperty("readFileAsDataURL",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsDataURL),exposeProperty("readFileAsBlob",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsBlob),exposeProperty("readFileAsTextSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsTextSync),exposeProperty("readFileAsBinaryStringSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsBinaryStringSync),exposeProperty("readFileAsDataURLSync",ZipArchiveReaderBlob,ZipArchiveReaderBlob.prototype.readFileAsDataURLSync),zip.unpack=defun(["buffer","encoding","chunkSize"],function(a,b,c){return new(a instanceof Blob?ZipArchiveReaderBlob:ZipArchiveReader)({buffer:a,encoding:b,chunkSize:c}).init()}),expose("jz.zip.unpack",zip.unpack);}).call(this); \ No newline at end of file diff --git a/src/ZipArchiveWriter.js b/src/ZipArchiveWriter.js index e1a5a86..0b4b7ad 100644 --- a/src/ZipArchiveWriter.js +++ b/src/ZipArchiveWriter.js @@ -15,16 +15,15 @@ * .write('a.mp3', mp3Buff) * .writeEnd(); */ -function ZipArchiveWriter(shareMemory, chunkSize) { - var params = utils.getParams(arguments, ['shareMemory', 'chunkSize']); - this.shareMemory = params.shareMemory; - this.chunkSize = params.chunkSize; +var ZipArchiveWriter = defun(['shareMemory', 'chunkSize'], function ZipArchiveWriter(shareMemory, chunkSize) { + this.shareMemory = shareMemory; + this.chunkSize = chunkSize; this.dirs = {}; this.centralDirHeaders = []; this.offset = 0; this.date = new Date; this.listners = {}; -} +}); /** * @param {string} path diff --git a/src/algorithms/crc32.js b/src/algorithms/crc32.js index d1ffa83..ac2a9d2 100644 --- a/src/algorithms/crc32.js +++ b/src/algorithms/crc32.js @@ -24,16 +24,15 @@ algorithms.crc32 = (function(){ return table; })(); - return function(buffer, crc){ - var params = utils.getParams(arguments, ['buffer', 'crc']), - bytes = utils.toBytes(params.buffer), - crc = params.crc == null ? 0xFFFFFFFF : ~params.crc >>> 0, + return defun(['buffer', 'crc'], function(buffer, crc){ + var bytes = utils.toBytes(buffer), + crc = crc == null ? 0xFFFFFFFF : ~crc >>> 0, i = 0, n = bytes.length, t = table; for(; i < n; ++i) crc = (crc >>> 8) ^ t[bytes[i] ^ (crc & 0xFF)]; return ~crc >>> 0; - }; + }); })(); expose('jz.algorithms.crc32', algorithms.crc32); \ No newline at end of file diff --git a/src/algorithms/deflate.js b/src/algorithms/deflate.js index 8eb1928..f3f1a31 100644 --- a/src/algorithms/deflate.js +++ b/src/algorithms/deflate.js @@ -9,9 +9,8 @@ utils.js * @param {number} level * @return {Uint8Array} */ -algorithms.deflate = function (buffer, level, chunkSize) { - var params = utils.getParams(arguments, ['buffer', 'level', 'chunkSize']); - return zlib['rawDeflate'](utils.toBytes(params.buffer), params.level, params.chunkSize); -}; +algorithms.deflate = defun(['buffer', 'level', 'chunkSize'], function(buffer, level, chunkSize) { + return zlib['rawDeflate'](utils.toBytes(buffer), level, chunkSize); +}); expose('jz.algorithms.deflate', algorithms.deflate); \ No newline at end of file diff --git a/src/algorithms/inflate.js b/src/algorithms/inflate.js index 80bee1b..5aceb65 100644 --- a/src/algorithms/inflate.js +++ b/src/algorithms/inflate.js @@ -3,9 +3,8 @@ * @param {number} chunkSize * @return {Uint8Array} */ -algorithms.inflate = function(buffer, chunkSize){ - var params = utils.getParams(arguments, ['buffer', 'chunkSize']); - return zlib['rawInflate'](utils.toBytes(params.buffer), params.chunkSize); -}; +algorithms.inflate = defun(['buffer', 'chunkSize'], function(buffer, chunkSize){ + return zlib['rawInflate'](utils.toBytes(buffer), chunkSize); +}); expose('jz.algorithms.inflate', algorithms.inflate); \ No newline at end of file diff --git a/src/gz.compress.js b/src/gz.compress.js index 2fdc370..d5dc82f 100644 --- a/src/gz.compress.js +++ b/src/gz.compress.js @@ -6,20 +6,19 @@ * @param {string} fcomment * @return {Uint8Array} */ -gz.compress = function(buffer, level, chunkSize, fname, fcomment) { - var params = utils.getParams(arguments, ['buffer', 'level', 'chunkSize', 'fname', 'fcomment']), - chunks = []; +gz.compress = defun(['buffer', 'level', 'chunkSize', 'fname', 'fcomment'], function(buffer, level, chunkSize, fname, fcomment) { + var chunks = []; stream.gz.compress({ - buffer: params.buffer, - level: params.level, - chunkSize: params.chunkSize, - fname: params.fname, - fcomment: params.fcomments, + buffer: buffer, + level: level, + chunkSize: chunkSize, + fname: fname, + fcomment: fcomment, streamFn: function(chunk) { chunks.push(chunk); } }); return utils.concatBytes(chunks); -}; +}); expose('jz.gz.compress', gz.compress); \ No newline at end of file diff --git a/src/gz.decompress.js b/src/gz.decompress.js index 53f12d0..3325f6d 100644 --- a/src/gz.decompress.js +++ b/src/gz.decompress.js @@ -5,18 +5,16 @@ * @param {boolean} chunkSize * @return {Uint8Array} */ -gz.decompress = function(buffer, chunkSize) { - var params = utils.getParams(arguments, ['buffer', 'chunkSize']), - chunks = []; +gz.decompress = defun(['buffer', 'chunkSize'], function(buffer, chunkSize) { + var chunks = []; stream.gz.decompress({ - buffer: params.buffer, + buffer: buffer, streamFn: function(chunk) { chunks.push(chunk); }, - shareMemory: false, - chunkSize: params.chunkSize + chunkSize: chunkSize }); return utils.concatBytes(chunks); -} +}); expose('jz.gz.decompress', gz.decompress); \ No newline at end of file diff --git a/src/jsziptools.js b/src/jsziptools.js index ec524a4..691cc90 100644 --- a/src/jsziptools.js +++ b/src/jsziptools.js @@ -34,3 +34,17 @@ function expose(namespace, o) { function exposeProperty(name, cls, property) { cls.prototype[name] = property; } + +function defun(propertyNames, fn) { + return function() { + var args, params = arguments[0]; + if (Object.prototype.toString.call(params) === '[object Object]') { + args = propertyNames.map(function(name) { + return params[name]; + }); + } else { + args = arguments; + } + return fn.apply(this, args); + }; +} \ No newline at end of file diff --git a/src/stream/algorithms/deflate.js b/src/stream/algorithms/deflate.js index caff98a..5ba8164 100644 --- a/src/stream/algorithms/deflate.js +++ b/src/stream/algorithms/deflate.js @@ -14,10 +14,14 @@ * chunkSize: 0xf000 * }); */ -stream.algorithms.deflate = function(buffer, streamFn, level, shareMemory, chunkSize) { - var params = utils.getParams(arguments, ['buffer', 'streamFn', 'level', 'shareMemory', 'chunkSize']); - params.input = utils.toBytes(params.buffer); - zlib.stream.rawDeflate(params); -}; +stream.algorithms.deflate = defun(['buffer', 'streamFn', 'level', 'shareMemory', 'chunkSize'], function(buffer, streamFn, level, shareMemory, chunkSize) { + zlib.stream.rawDeflate({ + input: utils.toBytes(buffer), + streamFn: streamFn, + level: level, + shareMemory: shareMemory, + chunkSize: chunkSize + }); +}); expose('jz.stream.algorithms.deflate', stream.algorithms.deflate); \ No newline at end of file diff --git a/src/stream/algorithms/inflate.js b/src/stream/algorithms/inflate.js index 212357e..acc46d6 100644 --- a/src/stream/algorithms/inflate.js +++ b/src/stream/algorithms/inflate.js @@ -13,10 +13,13 @@ * chunkSize: 0xf000 * }); */ -stream.algorithms.inflate = function(buffer, streamFn, shareMemory, chunkSize) { - var params = utils.getParams(arguments, ['buffer', 'streamFn', 'shareMemory', 'chunkSize']); - params.input = utils.toBytes(params.buffer); - zlib.stream.rawInflate(params); -}; +stream.algorithms.inflate = defun(['buffer', 'streamFn', 'shareMemory', 'chunkSize'], function(buffer, streamFn, shareMemory, chunkSize) { + zlib.stream.rawInflate({ + input: utils.toBytes(buffer), + streamFn: streamFn, + shareMemory: shareMemory, + chunkSize: chunkSize + }); +}); expose('jz.stream.algorithms.inflate', stream.algorithms.inflate); \ No newline at end of file diff --git a/src/stream/gz.compress.js b/src/stream/gz.compress.js index f74cad5..7fa8e1d 100644 --- a/src/stream/gz.compress.js +++ b/src/stream/gz.compress.js @@ -9,15 +9,10 @@ * @param {string} fname - optional * @param {string} fcomment - optional */ -stream.gz.compress = function(buffer, streamFn, level, shareMemory, chunkSize, fname, fcomment) { - var params = utils.getParams(arguments, ['buffer', 'streamFn', 'level', 'shareMemory', 'chunkSize', 'fname', 'fcomment']), - bytes = utils.toBytes(params.buffer), - level = params.level, - streamFn = params.streamFn, - shareMemory = params.shareMemory, - chunkSize = params.chunkSize, - fname = params.fname && utils.toBytes(params.fname), - fcomment = params.fcomment && utils.toBytes(params.fcomment), +stream.gz.compress = defun(['buffer', 'streamFn', 'level', 'shareMemory', 'chunkSize', 'fname', 'fcomment'], function(buffer, streamFn, level, shareMemory, chunkSize, fname, fcomment) { + var bytes = utils.toBytes(buffer), + fname = fname && utils.toBytes(fname), + fcomment = fcomment && utils.toBytes(fcomment), flg = 0, headerLength = 10, offset = 0, @@ -70,6 +65,6 @@ stream.gz.compress = function(buffer, streamFn, level, shareMemory, chunkSize, f view.setUint32(0, algorithms.crc32(bytes), true); // crc checksum view.setUint32(4, bytes.length, true); // isize streamFn(footer); -}; +}); expose('jz.stream.gz.compress', stream.gz.compress); \ No newline at end of file diff --git a/src/stream/gz.decompress.js b/src/stream/gz.decompress.js index 0ee5361..61bb27e 100644 --- a/src/stream/gz.decompress.js +++ b/src/stream/gz.decompress.js @@ -4,12 +4,9 @@ * @param {boolean} shareMemory * @param {number} chunkSize */ -stream.gz.decompress = function(buffer, streamFn, shareMemory, chunkSize) { - var params = utils.getParams(arguments, ['buffer', 'streamFn', 'shareMemory', 'chunkSize']), - bytes = utils.toBytes(params.buffer), - flg, ret, crc, streamFn = params.streamFn, - shareMemory = params.shareMemory, - chunkSize = params.chunkSize, +stream.gz.decompress = defun(['buffer', 'streamFn', 'shareMemory', 'chunkSize'], function(buffer, streamFn, shareMemory, chunkSize) { + var bytes = utils.toBytes(buffer), + flg, ret, crc, offset = 10, view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); @@ -39,6 +36,6 @@ stream.gz.decompress = function(buffer, streamFn, shareMemory, chunkSize) { if (crc !== view.getUint32(bytes.length - 8, true)) { throw new Error('js.stream.gz.decompress: file is broken.'); } -}; +}); expose('jz.stream.gz.decompress', stream.gz.decompress); \ No newline at end of file diff --git a/src/stream/zip.pack.js b/src/stream/zip.pack.js index b249607..3511397 100644 --- a/src/stream/zip.pack.js +++ b/src/stream/zip.pack.js @@ -30,11 +30,10 @@ * // no args. * }); */ -stream.zip.pack = function(files, streamFn, level, shareMemory, chunkSize) { - var params = utils.getParams(arguments, ['files', 'streamFn', 'level', 'shareMemory', 'chunkSize']), - promises = [], - writer = new ZipArchiveWriter(params); - writer.on('data', params.streamFn); +stream.zip.pack = defun(['files', 'streamFn', 'level', 'shareMemory', 'chunkSize'], function(files, streamFn, level, shareMemory, chunkSize) { + var promises = [], + writer = new ZipArchiveWriter(shareMemory, chunkSize); + writer.on('data', streamFn); function packItem(level, path, item) { var dir = item.children || item.dir || item.folder, @@ -69,11 +68,11 @@ stream.zip.pack = function(files, streamFn, level, shareMemory, chunkSize) { } } - params.files.forEach(loadFile); + files.forEach(loadFile); return Promise.all(promises).then(function() { - params.files.forEach(packItem.bind(null, params.level, '')); + files.forEach(packItem.bind(null, level, '')); writer.writeEnd(); }); -}; +}); expose('jz.stream.zip.pack', stream.zip.pack); diff --git a/src/stream/zlib.compress.js b/src/stream/zlib.compress.js index 580c038..1bff6cd 100644 --- a/src/stream/zlib.compress.js +++ b/src/stream/zlib.compress.js @@ -15,10 +15,14 @@ * chunkSize: 0xf000 * }); */ -stream.zlib.compress = function(buffer, streamFn, level, shareMemory, chunkSize) { - var params = utils.getParams(arguments, ['buffer', 'streamFn', 'level', 'shareMemory', 'chunkSize']); - params.input = utils.toBytes(params.buffer); - zlib.stream.deflate(params); -}; +stream.zlib.compress = defun(['buffer', 'streamFn', 'level', 'shareMemory', 'chunkSize'], function(buffer, streamFn, level, shareMemory, chunkSize) { + zlib.stream.deflate({ + input: utils.toBytes(buffer), + streamFn: streamFn, + level: level, + shareMemory: shareMemory, + chunkSize: chunkSize + }); +}); expose('jz.stream.zlib.compress', stream.zlib.compress); \ No newline at end of file diff --git a/src/stream/zlib.decompress.js b/src/stream/zlib.decompress.js index f855073..b05b80a 100644 --- a/src/stream/zlib.decompress.js +++ b/src/stream/zlib.decompress.js @@ -12,10 +12,13 @@ * chunkSize: 0xf000 * }); */ -stream.zlib.decompress = function(buffer, streamFn, shareMemory, chunkSize) { - var params = utils.getParams(arguments, ['buffer', 'streamFn', 'shareMemory', 'chunkSize']); - params.input = utils.toBytes(params.buffer); - zlib.stream.inflate(params); -}; +stream.zlib.decompress = defun(['buffer', 'streamFn', 'shareMemory', 'chunkSize'], function(buffer, streamFn, shareMemory, chunkSize) { + zlib.stream.inflate({ + input: buffer, + streamFn: streamFn, + shareMemory: shareMemory, + chunkSize: chunkSize + }); +}); expose('jz.stream.zlib.decompress', stream.zlib.decompress); \ No newline at end of file diff --git a/src/zip.pack.js b/src/zip.pack.js index 761a134..3376461 100644 --- a/src/zip.pack.js +++ b/src/zip.pack.js @@ -23,20 +23,19 @@ * // buffer is Uint8Array. * }); */ -zip.pack = function(files, level, chunkSize) { - var params = utils.getParams(arguments, ['files', 'level', 'chunkSize']), - chunks = []; +zip.pack = defun(['files', 'level', 'chunkSize'], function(files, level, chunkSize) { + var chunks = []; return stream.zip.pack({ - files: params.files, + files: files, shareMemory: false, - level: params.level, - chunkSize: params.chunkSize, + level: level, + chunkSize: chunkSize, streamFn: function(chunk) { chunks.push(chunk); } }).then(function() { return utils.concatBytes(chunks); }); -}; +}); expose('jz.zip.pack', zip.pack); \ No newline at end of file diff --git a/src/zip.unpack.js b/src/zip.unpack.js index 206b3b9..60f2207 100644 --- a/src/zip.unpack.js +++ b/src/zip.unpack.js @@ -136,11 +136,11 @@ ZipArchiveReader.prototype._completeInit = function() { return Promise.all(localFileHeaders.map(function(header, i) { return utils.bytesToString(header.filename, params.encoding).then(function(filename) { - header.filename = filename; -}); -})).then(function() { - return self -}); + header.filename = filename; + }); + })).then(function() { + return self + }); }; /** @@ -602,9 +602,12 @@ exposeProperty('readFileAsDataURLSync', ZipArchiveReaderBlob, ZipArchiveReaderBl * }); * }); */ -zip.unpack = function(buffer, encoding, chunkSize) { - var params = utils.getParams(arguments, ['buffer', 'encoding', 'chunkSize']); - return new(params.buffer instanceof Blob ? ZipArchiveReaderBlob : ZipArchiveReader)(params).init(); -}; +zip.unpack = defun(['buffer', 'encoding', 'chunkSize'], function(buffer, encoding, chunkSize) { + return new(buffer instanceof Blob ? ZipArchiveReaderBlob : ZipArchiveReader)({ + buffer: buffer, + encoding: encoding, + chunkSize: chunkSize + }).init(); +}); expose('jz.zip.unpack', zip.unpack); \ No newline at end of file diff --git a/src/zlib.compress.js b/src/zlib.compress.js index 91ad98d..dbd5593 100644 --- a/src/zlib.compress.js +++ b/src/zlib.compress.js @@ -5,7 +5,6 @@ * @param {integer} level compression level. * @return {Uint8Array} */ -expose('jz.zlib.compress', function (buffer, level, chunkSize) { - var params = utils.getParams(arguments, ['buffer', 'level', 'chunkSize']); - return zlib['deflate'](utils.toBytes(params.buffer), params.level, params.chunkSize); -}); \ No newline at end of file +expose('jz.zlib.compress', defun(['buffer', 'level', 'chunkSize'], function (buffer, level, chunkSize) { + return zlib['deflate'](utils.toBytes(buffer), level, chunkSize); +})); \ No newline at end of file diff --git a/src/zlib.decompress.js b/src/zlib.decompress.js index b631342..46fdde0 100644 --- a/src/zlib.decompress.js +++ b/src/zlib.decompress.js @@ -4,7 +4,6 @@ * @param {ArrayBuffer|Uint8Array|Array|string} buffer zlib format buffer. * @return {Uint8Array} */ -expose('jz.zlib.decompress', function (buffer, chunkSize) { - var params = utils.getParams(arguments, ['buffer', 'chunkSize']); - return zlib['inflate'](utils.toBytes(params.buffer), params.chunkSize); -}); \ No newline at end of file +expose('jz.zlib.decompress', defun(['buffer', 'chunkSize'], function (buffer, chunkSize) { + return zlib['inflate'](utils.toBytes(buffer), chunkSize); +})); \ No newline at end of file