@zip.js/zip.js 2.6.1 → 2.6.2

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
@@ -51,8 +51,6 @@ const contentTextPromise = new Response(contentStream.readable).text();
51
51
 
52
52
  // Reads zipBlob via a BlobReader object, retrieves metadata (name, dates, etc.) of the first entry,
53
53
  // retrieves its content via contentStream, and closes the reader.
54
- // Note: it is *not* possible to use a ReadableStream object to read a zip because random access
55
- // to data is required to fetch entries reliably and efficiently.
56
54
  const zipReader = new ZipReader(new BlobReader(zipBlob));
57
55
  const firstEntry = (await zipReader.getEntries()).shift();
58
56
  await firstEntry.getData(contentStream);
@@ -8182,14 +8182,19 @@
8182
8182
 
8183
8183
  async* getEntriesGenerator(options = {}) {
8184
8184
  const zipReader = this;
8185
- const { reader, config } = zipReader;
8186
- if (!reader.initialized) {
8185
+ let { reader } = zipReader;
8186
+ const { config } = zipReader;
8187
+ if (!reader.initialized && reader.init) {
8187
8188
  await reader.init();
8188
8189
  }
8189
- reader.chunkSize = getChunkSize(config);
8190
+ if (reader.size === undefined || !reader.readUint8Array) {
8191
+ const blob = await new Response(reader.readable).blob();
8192
+ reader = new BlobReader(blob);
8193
+ }
8190
8194
  if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
8191
8195
  throw new Error(ERR_BAD_FORMAT);
8192
8196
  }
8197
+ reader.chunkSize = getChunkSize(config);
8193
8198
  const endOfDirectoryInfo = await seekSignature(reader, END_OF_CENTRAL_DIR_SIGNATURE, reader.size, END_OF_CENTRAL_DIR_LENGTH, MAX_16_BITS * 16);
8194
8199
  if (!endOfDirectoryInfo) {
8195
8200
  throw new Error(ERR_EOCDR_NOT_FOUND);