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

x/zipjs/index.d.ts>Reader

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

Represents an instance used to read unknown type of data.

Examples

Here is an example of custom Reader class used to read binary strings:

class BinaryStringReader extends Reader {

  constructor(binaryString) {
    super();
    this.binaryString = binaryString;
  }

  init() {
    super.init();
    this.size = this.binaryString.length;
  }

  readUint8Array(offset, length) {
    const result = new Uint8Array(length);
    for (let indexCharacter = 0; indexCharacter < length; indexCharacter++) {
      result[indexCharacter] = this.binaryString.charCodeAt(indexCharacter + offset) & 0xFF;
    }
    return result;
  }
}

Constructors

new
Reader(value: Type)

Creates the Reader instance

Properties

readable: ReadableStream

The ReadableStream instance.

size: number

The total size of the data in bytes.

Methods

optional
init(): Promise<void>

Initializes the instance asynchronously

readUint8Array(index: number, length: number): Promise<Uint8Array>

Reads a chunk of data