@zip.js/zip.js 2.6.13 → 2.6.14

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.
@@ -7951,18 +7951,19 @@
7951
7951
 
7952
7952
  class Uint8ArrayWriter extends Writer {
7953
7953
 
7954
- constructor() {
7955
- super();
7956
- this.array = new Uint8Array();
7954
+ init(initSize = 0) {
7955
+ this.array = new Uint8Array(initSize);
7957
7956
  }
7958
7957
 
7959
7958
  writeUint8Array(array) {
7960
- super.writeUint8Array(array);
7961
7959
  const writer = this;
7962
- const previousArray = writer.array;
7963
- writer.array = new Uint8Array(previousArray.length + array.length);
7964
- writer.array.set(previousArray);
7965
- writer.array.set(array, previousArray.length);
7960
+ if (writer.size + array.length > writer.array.length) {
7961
+ const previousArray = writer.array;
7962
+ writer.array = new Uint8Array(previousArray.length + array.length);
7963
+ writer.array.set(previousArray);
7964
+ }
7965
+ writer.array.set(array, writer.size);
7966
+ super.writeUint8Array(array);
7966
7967
  }
7967
7968
 
7968
7969
  getData() {
@@ -7976,9 +7977,9 @@
7976
7977
  return protocol == "http:" || protocol == "https:";
7977
7978
  }
7978
7979
 
7979
- async function initStream(stream) {
7980
+ async function initStream(stream, initSize) {
7980
7981
  if (stream.init && !stream.initialized) {
7981
- await stream.init();
7982
+ await stream.init(initSize);
7982
7983
  }
7983
7984
  }
7984
7985
 
@@ -8397,6 +8398,7 @@
8397
8398
  bitFlag,
8398
8399
  signature,
8399
8400
  rawLastModDate,
8401
+ uncompressedSize,
8400
8402
  compressedSize
8401
8403
  } = zipEntry;
8402
8404
  const localDirectory = zipEntry.localDirectory = {};
@@ -8437,7 +8439,7 @@
8437
8439
  readable.size = size;
8438
8440
  const { writable } = writer;
8439
8441
  const signal = getOptionValue$1(zipEntry, options, "signal");
8440
- await initStream(writer);
8442
+ await initStream(writer, uncompressedSize);
8441
8443
  const { onstart, onprogress, onend } = options;
8442
8444
  const workerOptions = {
8443
8445
  options: {
@@ -9586,7 +9588,7 @@
9586
9588
  return zipEntry.data;
9587
9589
  } else {
9588
9590
  const reader = zipEntry.reader = new zipEntry.Reader(zipEntry.data, options);
9589
- await Promise.all([initStream(reader), initStream(writer)]);
9591
+ await Promise.all([initStream(reader), initStream(writer, zipEntry.data.uncompressedSize)]);
9590
9592
  zipEntry.uncompressedSize = reader.size;
9591
9593
  const readable = reader.readable;
9592
9594
  readable.size = () => reader.size;