unzipit 1.3.5 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,7 +25,7 @@ async function readFiles(url) {
25
25
  const {entries} = await unzip(url);
26
26
 
27
27
  // print all entries and their sizes
28
- for (const [name, entry] in Object.entries(entries)) {
28
+ for (const [name, entry] of Object.entries(entries)) {
29
29
  console.log(name, entry.size);
30
30
  }
31
31
 
@@ -250,17 +250,26 @@ Advantages over other libraries.
250
250
  * UZIP requires the entire compressed file to be in memory and
251
251
  the entire uncompressed contents of all the files to be in memory.
252
252
 
253
- * fflate requires all uncompressed files in memory at once.
254
- It also must read the entire zip file though it does not
255
- require to be all in memory at once.
256
-
257
253
  * Yauzl does not require all the files to be in memory but
258
254
  they do have to be read in order and it has very peculiar API where
259
255
  you still have to manually go through all the entries even if
260
256
  you don't choose to read their contents. Further it's node only.
261
257
 
262
- Unzipit does not require all content to be in memory. If you use a Blob
263
- the browser can effectively virtualize access so it doesn't have to be in memory. Only the entries you access use memory.
258
+ * fflate has 2 modes. One the entire contents of all
259
+ uncompressed files are provided therefore using lots
260
+ of memory. The other is like Yauzl where you're required
261
+ to handle every file but you can choose to ignore
262
+ certain ones. Further in this mode (maybe both modes) are
263
+ not standards compliant. It scans for files but that is not
264
+ a valid way to read a zip file. The only valid way to read a zip file
265
+ is to jump to the end of the file and find the table of
266
+ contents. So, fflate will fail on perfectly valid zip files.
267
+
268
+ Unzipit does not require all compressed content nor all uncompressed
269
+ content to be in memory. Only the entries you access use memory.
270
+ If you use a Blob as input the browser can effectively virtualize
271
+ access so it doesn't have to be in memory and unzipit will only
272
+ access the parts of the blob needed to read the content you request.
264
273
 
265
274
  Further, if you use the `HTTPRangeReader` or similar, unzipit only
266
275
  downloads/reads the parts of the zip file you actually use, saving you
@@ -1,4 +1,4 @@
1
- /* unzipit@1.3.3, license MIT */
1
+ /* unzipit@1.3.6, license MIT */
2
2
  (function (factory) {
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  factory();
@@ -245,24 +245,24 @@
245
245
  */
246
246
  })();
247
247
 
248
- const crc = {
249
- table : ( function() {
250
- var tab = new Uint32Array(256);
251
- for (var n=0; n<256; n++) {
252
- var c = n;
253
- for (var k=0; k<8; k++) {
254
- if (c & 1) c = 0xedb88320 ^ (c >>> 1);
255
- else c = c >>> 1;
256
- }
257
- tab[n] = c; }
258
- return tab; })(),
259
- update : function(c, buf, off, len) {
260
- for (var i=0; i<len; i++) c = crc.table[(c ^ buf[off+i]) & 0xff] ^ (c >>> 8);
261
- return c;
262
- },
263
- crc : function(b,o,l) { return crc.update(0xffffffff,b,o,l) ^ 0xffffffff; }
264
- };
265
-
248
+ const crc = {
249
+ table : ( function() {
250
+ var tab = new Uint32Array(256);
251
+ for (var n=0; n<256; n++) {
252
+ var c = n;
253
+ for (var k=0; k<8; k++) {
254
+ if (c & 1) c = 0xedb88320 ^ (c >>> 1);
255
+ else c = c >>> 1;
256
+ }
257
+ tab[n] = c; }
258
+ return tab; })(),
259
+ update : function(c, buf, off, len) {
260
+ for (var i=0; i<len; i++) c = crc.table[(c ^ buf[off+i]) & 0xff] ^ (c >>> 8);
261
+ return c;
262
+ },
263
+ crc : function(b,o,l) { return crc.update(0xffffffff,b,o,l) ^ 0xffffffff; }
264
+ };
265
+
266
266
  function inflateRaw(file, buf) { return inflate(file, buf); }
267
267
 
268
268
  /* global SharedArrayBuffer, process */
@@ -1,4 +1,4 @@
1
- /* unzipit@1.3.3, license MIT */
1
+ /* unzipit@1.3.6, license MIT */
2
2
  'use strict';(function(w){"function"===typeof define&&define.amd?define(w):w()})(function(){function w(a,b){var e=a.length;if(b<=e)return a;b=new Uint8Array(Math.max(e<<1,b));b.set(a,0);return b}function X(a,b,e,g){for(var f=0,c=0,m=g.length>>>1;c<e;){var p=a[c+b];g[c<<1]=0;g[(c<<1)+1]=p;p>f&&(f=p);c++}for(;c<m;)g[c<<1]=0,g[(c<<1)+1]=0,c++;return f}function z(a,b){var e=a.length,g,f;var c=d.bl_count;for(f=0;f<=b;f++)c[f]=0;for(f=1;f<e;f+=2)c[a[f]]++;f=d.next_code;var m=0;c[0]=0;for(g=1;g<=b;g++)m=
3
3
  m+c[g-1]<<1,f[g]=m;for(b=0;b<e;b+=2)c=a[b+1],0!=c&&(a[b]=f[c],f[c]++)}function A(a,b,e){for(var g=a.length,f=d.rev15,c=0;c<g;c+=2)if(0!=a[c+1]){var m=a[c+1],p=c>>1<<4|m,t=b-m;m=a[c]<<t;for(t=m+(1<<t);m!=t;)e[f[m]>>>15-b]=p,m++}}function Y(a,b){for(var e=d.rev15,g=15-b,f=0;f<a.length;f+=2)a[f]=e[a[f]<<b-a[f+1]]>>>g}function x(a,b,e){return(a[b>>>3]|a[(b>>>3)+1]<<8)>>>(b&7)&(1<<e)-1}function K(a,b,e){return(a[b>>>3]|a[(b>>>3)+1]<<8|a[(b>>>3)+2]<<16)>>>(b&7)&(1<<e)-1}function L(a,b){return(a[b>>>3]|
4
4
  a[(b>>>3)+1]<<8|a[(b>>>3)+2]<<16)>>>(b&7)}function fa(a){return a.arrayBuffer?a.arrayBuffer():new Promise((b,e)=>{const g=new FileReader;g.addEventListener("loadend",()=>{b(g.result)});g.addEventListener("error",e);g.readAsArrayBuffer(a)})}async function ha(a){a=await fa(a);return new Uint8Array(a)}const d=function(){var a=Uint16Array,b=Uint32Array;return{next_code:new a(16),bl_count:new a(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,
@@ -1,4 +1,4 @@
1
- /* unzipit@1.3.3, license MIT */
1
+ /* unzipit@1.3.6, license MIT */
2
2
  function inflate(data, buf) {
3
3
  var u8=Uint8Array;
4
4
  if(data[0]==3 && data[1]==0) return (buf ? buf : new u8(0));
@@ -240,24 +240,24 @@ const U = function(){
240
240
  */
241
241
  })();
242
242
 
243
- const crc = {
244
- table : ( function() {
245
- var tab = new Uint32Array(256);
246
- for (var n=0; n<256; n++) {
247
- var c = n;
248
- for (var k=0; k<8; k++) {
249
- if (c & 1) c = 0xedb88320 ^ (c >>> 1);
250
- else c = c >>> 1;
251
- }
252
- tab[n] = c; }
253
- return tab; })(),
254
- update : function(c, buf, off, len) {
255
- for (var i=0; i<len; i++) c = crc.table[(c ^ buf[off+i]) & 0xff] ^ (c >>> 8);
256
- return c;
257
- },
258
- crc : function(b,o,l) { return crc.update(0xffffffff,b,o,l) ^ 0xffffffff; }
259
- };
260
-
243
+ const crc = {
244
+ table : ( function() {
245
+ var tab = new Uint32Array(256);
246
+ for (var n=0; n<256; n++) {
247
+ var c = n;
248
+ for (var k=0; k<8; k++) {
249
+ if (c & 1) c = 0xedb88320 ^ (c >>> 1);
250
+ else c = c >>> 1;
251
+ }
252
+ tab[n] = c; }
253
+ return tab; })(),
254
+ update : function(c, buf, off, len) {
255
+ for (var i=0; i<len; i++) c = crc.table[(c ^ buf[off+i]) & 0xff] ^ (c >>> 8);
256
+ return c;
257
+ },
258
+ crc : function(b,o,l) { return crc.update(0xffffffff,b,o,l) ^ 0xffffffff; }
259
+ };
260
+
261
261
  function inflateRaw(file, buf) { return inflate(file, buf); }
262
262
 
263
263
  /* global SharedArrayBuffer, process */
package/dist/unzipit.d.ts CHANGED
@@ -5,7 +5,7 @@ export type ZipInfo = {
5
5
 
6
6
  export type ZipInfoRaw = {
7
7
  zip: Zip,
8
- entries: [ZipEntry],
8
+ entries: ZipEntry[],
9
9
  };
10
10
 
11
11
  export type Zip = {
package/dist/unzipit.js CHANGED
@@ -1,4 +1,4 @@
1
- /* unzipit@1.3.3, license MIT */
1
+ /* unzipit@1.3.6, license MIT */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
4
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -350,24 +350,24 @@
350
350
  */
351
351
  })();
352
352
 
353
- const crc = {
354
- table : ( function() {
355
- var tab = new Uint32Array(256);
356
- for (var n=0; n<256; n++) {
357
- var c = n;
358
- for (var k=0; k<8; k++) {
359
- if (c & 1) c = 0xedb88320 ^ (c >>> 1);
360
- else c = c >>> 1;
361
- }
362
- tab[n] = c; }
363
- return tab; })(),
364
- update : function(c, buf, off, len) {
365
- for (var i=0; i<len; i++) c = crc.table[(c ^ buf[off+i]) & 0xff] ^ (c >>> 8);
366
- return c;
367
- },
368
- crc : function(b,o,l) { return crc.update(0xffffffff,b,o,l) ^ 0xffffffff; }
369
- };
370
-
353
+ const crc = {
354
+ table : ( function() {
355
+ var tab = new Uint32Array(256);
356
+ for (var n=0; n<256; n++) {
357
+ var c = n;
358
+ for (var k=0; k<8; k++) {
359
+ if (c & 1) c = 0xedb88320 ^ (c >>> 1);
360
+ else c = c >>> 1;
361
+ }
362
+ tab[n] = c; }
363
+ return tab; })(),
364
+ update : function(c, buf, off, len) {
365
+ for (var i=0; i<len; i++) c = crc.table[(c ^ buf[off+i]) & 0xff] ^ (c >>> 8);
366
+ return c;
367
+ },
368
+ crc : function(b,o,l) { return crc.update(0xffffffff,b,o,l) ^ 0xffffffff; }
369
+ };
370
+
371
371
  function inflateRaw(file, buf) { return inflate(file, buf); }
372
372
 
373
373
  /* global module */
@@ -1,4 +1,4 @@
1
- /* unzipit@1.3.3, license MIT */
1
+ /* unzipit@1.3.6, license MIT */
2
2
  'use strict';(function(z,G){"object"===typeof exports&&"undefined"!==typeof module?G(exports):"function"===typeof define&&define.amd?define(["exports"],G):(z="undefined"!==typeof globalThis?globalThis:z||self,G(z.unzipit={}))})(this,function(z){function G(a){return a.arrayBuffer?a.arrayBuffer():new Promise((b,c)=>{const e=new FileReader;e.addEventListener("loadend",()=>{b(e.result)});e.addEventListener("error",c);e.readAsArrayBuffer(a)})}async function na(a){a=await G(a);return new Uint8Array(a)}
3
3
  function aa(a){return"undefined"!==typeof Blob&&a instanceof Blob}function I(a){return"undefined"!==typeof SharedArrayBuffer&&a instanceof SharedArrayBuffer}function R(a,b){var c=a.length;if(b<=c)return a;b=new Uint8Array(Math.max(c<<1,b));b.set(a,0);return b}function oa(a,b,c,e,d,h){for(var k=ba,f=ca,l=0;l<c;){var n=a[f(e,d)&b];d+=n&15;var u=n>>>4;if(15>=u)h[l]=u,l++;else{var x=n=0;16==u?(x=3+k(e,d,2),d+=2,n=h[l-1]):17==u?(x=3+k(e,d,3),d+=3):18==u&&(x=11+k(e,d,7),d+=7);for(u=l+x;l<u;)h[l]=n,l++}}return d}
4
4
  function da(a,b,c,e){for(var d=0,h=0,k=e.length>>>1;h<c;){var f=a[h+b];e[h<<1]=0;e[(h<<1)+1]=f;f>d&&(d=f);h++}for(;h<k;)e[h<<1]=0,e[(h<<1)+1]=0,h++;return d}function J(a,b){var c=a.length,e,d;var h=g.bl_count;for(d=0;d<=b;d++)h[d]=0;for(d=1;d<c;d+=2)h[a[d]]++;d=g.next_code;var k=0;h[0]=0;for(e=1;e<=b;e++)k=k+h[e-1]<<1,d[e]=k;for(b=0;b<c;b+=2)h=a[b+1],0!=h&&(a[b]=d[h],d[h]++)}function K(a,b,c){for(var e=a.length,d=g.rev15,h=0;h<e;h+=2)if(0!=a[h+1]){var k=a[h+1],f=h>>1<<4|k,l=b-k;k=a[h]<<l;for(l=k+
@@ -5,7 +5,7 @@ export type ZipInfo = {
5
5
 
6
6
  export type ZipInfoRaw = {
7
7
  zip: Zip,
8
- entries: [ZipEntry],
8
+ entries: ZipEntry[],
9
9
  };
10
10
 
11
11
  export type Zip = {
@@ -1,4 +1,4 @@
1
- /* unzipit@1.3.3, license MIT */
1
+ /* unzipit@1.3.6, license MIT */
2
2
  /* global SharedArrayBuffer, process */
3
3
 
4
4
  function readBlobAsArrayBuffer(blob) {
@@ -344,24 +344,24 @@ const U = function(){
344
344
  */
345
345
  })();
346
346
 
347
- const crc = {
348
- table : ( function() {
349
- var tab = new Uint32Array(256);
350
- for (var n=0; n<256; n++) {
351
- var c = n;
352
- for (var k=0; k<8; k++) {
353
- if (c & 1) c = 0xedb88320 ^ (c >>> 1);
354
- else c = c >>> 1;
355
- }
356
- tab[n] = c; }
357
- return tab; })(),
358
- update : function(c, buf, off, len) {
359
- for (var i=0; i<len; i++) c = crc.table[(c ^ buf[off+i]) & 0xff] ^ (c >>> 8);
360
- return c;
361
- },
362
- crc : function(b,o,l) { return crc.update(0xffffffff,b,o,l) ^ 0xffffffff; }
363
- };
364
-
347
+ const crc = {
348
+ table : ( function() {
349
+ var tab = new Uint32Array(256);
350
+ for (var n=0; n<256; n++) {
351
+ var c = n;
352
+ for (var k=0; k<8; k++) {
353
+ if (c & 1) c = 0xedb88320 ^ (c >>> 1);
354
+ else c = c >>> 1;
355
+ }
356
+ tab[n] = c; }
357
+ return tab; })(),
358
+ update : function(c, buf, off, len) {
359
+ for (var i=0; i<len; i++) c = crc.table[(c ^ buf[off+i]) & 0xff] ^ (c >>> 8);
360
+ return c;
361
+ },
362
+ crc : function(b,o,l) { return crc.update(0xffffffff,b,o,l) ^ 0xffffffff; }
363
+ };
364
+
365
365
  function inflateRaw(file, buf) { return inflate(file, buf); }
366
366
 
367
367
  /* global module */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unzipit",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "random access unzip library for JavaScript",
5
5
  "main": "dist/unzipit.js",
6
6
  "module": "dist/unzipit.module.js",