@zip.js/zip.js 2.7.5 → 2.7.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.
@@ -367,25 +367,36 @@ class ZipDirectoryEntry extends ZipEntry {
367
367
  const zipReader = new ZipReader(reader, options);
368
368
  const importedEntries = [];
369
369
  const entries = await zipReader.getEntries();
370
- entries.forEach((entry) => {
370
+ for (const entry of entries) {
371
371
  let parent = this;
372
- const path = entry.filename.split("/");
373
- const name = path.pop();
374
- path.forEach((pathPart, pathIndex) => {
375
- const previousParent = parent;
376
- parent = parent.getChildByName(pathPart);
377
- if (!parent) {
378
- parent = new ZipDirectoryEntry(this.fs, pathPart, { data: pathIndex == path.length - 1 ? entry : null }, previousParent);
379
- importedEntries.push(parent);
372
+ try {
373
+ const path = entry.filename.split("/");
374
+ const name = path.pop();
375
+ path.forEach((pathPart, pathIndex) => {
376
+ const previousParent = parent;
377
+ parent = parent.getChildByName(pathPart);
378
+ if (!parent) {
379
+ parent = new ZipDirectoryEntry(this.fs, pathPart, { data: pathIndex == path.length - 1 ? entry : null }, previousParent);
380
+ importedEntries.push(parent);
381
+ }
382
+ });
383
+ if (!entry.directory) {
384
+ importedEntries.push(addChild(parent, name, {
385
+ data: entry,
386
+ Reader: getZipBlobReader(Object.assign({}, options))
387
+ }));
380
388
  }
381
- });
382
- if (!entry.directory) {
383
- importedEntries.push(addChild(parent, name, {
384
- data: entry,
385
- Reader: getZipBlobReader(Object.assign({}, options))
386
- }));
389
+ } catch (error) {
390
+ try {
391
+ error.cause = {
392
+ entry
393
+ };
394
+ } catch (_error) {
395
+ // ignored
396
+ }
397
+ throw error;
387
398
  }
388
- });
399
+ }
389
400
  return importedEntries;
390
401
  }
391
402
 
@@ -620,6 +631,9 @@ async function initReaders(entry, options) {
620
631
  } catch (error) {
621
632
  try {
622
633
  error.entryId = child.id;
634
+ error.cause = {
635
+ entry: child
636
+ };
623
637
  } catch (_error) {
624
638
  // ignored
625
639
  }
@@ -652,7 +666,7 @@ async function exportZip(zipWriter, entry, totalSize, options) {
652
666
 
653
667
  async function exportChild() {
654
668
  if (options.bufferedWrite) {
655
- await Promise.all(entry.children.map(processChild));
669
+ await Promise.allSettled(entry.children.map(processChild));
656
670
  } else {
657
671
  for (const child of entry.children) {
658
672
  await processChild(child);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A JavaScript library to zip and unzip files in the browser, Deno and Node.js",
4
4
  "author": "Gildas Lormeau",
5
5
  "license": "BSD-3-Clause",
6
- "version": "2.7.5",
6
+ "version": "2.7.6",
7
7
  "type": "module",
8
8
  "keywords": [
9
9
  "zip",