@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.
package/dist/zip-full.js CHANGED
@@ -6950,18 +6950,19 @@
6950
6950
 
6951
6951
  class Uint8ArrayWriter extends Writer {
6952
6952
 
6953
- constructor() {
6954
- super();
6955
- this.array = new Uint8Array();
6953
+ init(initSize = 0) {
6954
+ this.array = new Uint8Array(initSize);
6956
6955
  }
6957
6956
 
6958
6957
  writeUint8Array(array) {
6959
- super.writeUint8Array(array);
6960
6958
  const writer = this;
6961
- const previousArray = writer.array;
6962
- writer.array = new Uint8Array(previousArray.length + array.length);
6963
- writer.array.set(previousArray);
6964
- writer.array.set(array, previousArray.length);
6959
+ if (writer.size + array.length > writer.array.length) {
6960
+ const previousArray = writer.array;
6961
+ writer.array = new Uint8Array(previousArray.length + array.length);
6962
+ writer.array.set(previousArray);
6963
+ }
6964
+ writer.array.set(array, writer.size);
6965
+ super.writeUint8Array(array);
6965
6966
  }
6966
6967
 
6967
6968
  getData() {
@@ -6975,9 +6976,9 @@
6975
6976
  return protocol == "http:" || protocol == "https:";
6976
6977
  }
6977
6978
 
6978
- async function initStream(stream) {
6979
+ async function initStream(stream, initSize) {
6979
6980
  if (stream.init && !stream.initialized) {
6980
- await stream.init();
6981
+ await stream.init(initSize);
6981
6982
  }
6982
6983
  }
6983
6984
 
@@ -7396,6 +7397,7 @@
7396
7397
  bitFlag,
7397
7398
  signature,
7398
7399
  rawLastModDate,
7400
+ uncompressedSize,
7399
7401
  compressedSize
7400
7402
  } = zipEntry;
7401
7403
  const localDirectory = zipEntry.localDirectory = {};
@@ -7436,7 +7438,7 @@
7436
7438
  readable.size = size;
7437
7439
  const { writable } = writer;
7438
7440
  const signal = getOptionValue$1(zipEntry, options, "signal");
7439
- await initStream(writer);
7441
+ await initStream(writer, uncompressedSize);
7440
7442
  const { onstart, onprogress, onend } = options;
7441
7443
  const workerOptions = {
7442
7444
  options: {