Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/101arrowz/fflate
Browse files Browse the repository at this point in the history
  • Loading branch information
101arrowz committed Mar 10, 2021
2 parents a9fa904 + 774b668 commit a6f1c63
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ unzipper.onfile = file => {
}
};

// Try to keep under 5,000 files per chunk to avoid stack limit errors
// For example, if all files are a few kB, multi-megabyte chunks are OK
// If files are mostly under 100 bytes, 64kB chunks are the limit
unzipper.push(zipChunk1);
unzipper.push(zipChunk2);
unzipper.push(zipChunk3, true);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fflate",
"version": "0.6.5",
"version": "0.6.7",
"description": "High performance (de)compression in an 8kB package",
"main": "./lib/index.cjs",
"module": "./esm/browser.js",
Expand Down
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3004,7 +3004,7 @@ export class Unzip {
*/
push(chunk: Uint8Array, final?: boolean) {
if (!this.onfile) throw 'no callback';
if (!this.k) throw 'stream finished';
if (!this.p) throw 'stream finished';
if (this.c > 0) {
const len = Math.min(this.c, chunk.length);
const toAdd = chunk.subarray(0, len);
Expand Down Expand Up @@ -3039,6 +3039,7 @@ export class Unzip {
else if (dd) sc = -1;
i += es;
this.c = sc;
let d: UnzipDecoder;
const file = {
name: fn,
compression: cmp,
Expand All @@ -3048,15 +3049,15 @@ export class Unzip {
else {
const ctr = this.o[cmp];
if (!ctr) throw 'unknown compression type ' + cmp;
const d = sc < 0 ? new ctr(fn) : new ctr(fn, sc, su);
d = sc < 0 ? new ctr(fn) : new ctr(fn, sc, su);
d.ondata = (err, dat, final) => { file.ondata(err, dat, final); }
for (const dat of chks) d.push(dat, false);
if (this.k[0] == chks) this.d = d;
if (this.k[0] == chks && this.c) this.d = d;
else d.push(et, true);
}
},
terminate: () => {
if (this.k[0] == chks && this.d.terminate) this.d.terminate();
if (d && d.terminate) d.terminate();
}
} as UnzipFile;
if (sc >= 0) file.size = sc, file.originalSize = su;
Expand Down Expand Up @@ -3084,7 +3085,7 @@ export class Unzip {
}
if (final) {
if (this.c) throw 'invalid zip file';
this.k = null;
this.p = null;
}
}

Expand Down
3 changes: 1 addition & 2 deletions test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const testFiles = {

const testZipFiles = {
model3D: 'https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/models/kmz/Box.kmz',
largeModel3D: 'https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/models/3mf/truck.3mf',
repo: 'https://codeload.github.com/parcel-bundler/parcel/zip/v2'
largeModel3D: 'https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/models/3mf/truck.3mf'
};

const dlCached = async <T extends Record<string, string | Buffer>>(files: T) => {
Expand Down

0 comments on commit a6f1c63

Please sign in to comment.