Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/zipjs/index.d.ts>ZipReader

JavaScript library to zip and unzip files supporting multi-core compression, compression streams, Zip64 and encryption.
Go to Latest
class ZipReader
import { ZipReader } from "https://deno.land/x/zipjs@v2.6.55/index.d.ts";

Represents an instance used to read a zip file.

Examples

Here is an example showing how to read the text data of the first entry from a zip file:

// create a BlobReader to read with a ZipReader the zip from a Blob object
const reader = new zip.ZipReader(new zip.BlobReader(blob));

// get all entries from the zip
const entries = await reader.getEntries();
if (entries.length) {

  // get first entry content as text by using a TextWriter
  const text = await entries[0].getData(
    // writer
    new zip.TextWriter(),
    // options
    {
      onprogress: (index, max) => {
        // onprogress callback
      }
    }
  );
  // text contains the entry data as a String
  console.log(text);
}

// close the ZipReader
await reader.close();

Constructors

new
ZipReader(reader:
| ReadableReader
| Reader<unknown>[]
| ReadableReader[]
, options?: ZipReaderConstructorOptions
)

Creates the instance

Properties

optional
appendedData: Uint8Array

The data appended after the zip file.

comment: Uint8Array

The global comment of the zip file.

optional
prependedData: Uint8Array

The data prepended before the zip file.

Methods

close(): Promise<void>

Closes the zip file

getEntries(options?: ZipReaderGetEntriesOptions): Promise<Entry[]>

Returns all the entries in the zip file

getEntriesGenerator(options?: ZipReaderGetEntriesOptions): AsyncGenerator<Entry, boolean>

Returns a generator used to iterate on all the entries in the zip file