Class ZipWriterStream

Represents an instance used to create a zipped stream.

Example

This example creates a zipped file called numbers.txt.zip containing the numbers 0 - 1000 each on their own line.

const readable = ReadableStream.from((function* () {
for (let i = 0; i < 1000; ++i)
yield i + '\n'
})())

readable
.pipeThrough(new ZipWriterStream().transform('numbers.txt'))
.pipeTo((await Deno.create('numbers.txt.zip')).writable)

Example

This example creates a zipped file called Archive.zip containing two files called numbers.txt and letters.txt

const readable1 = ReadableStream.from((function* () {
for (let i = 0; i < 1000; ++i)
yield i + '\n'
})())
const readable2 = ReadableStream.from((function* () {
const letters = 'abcdefghijklmnopqrstuvwxyz'.split('')
while (letters.length)
yield letters.shift() + '\n'
})())

const zipper = new ZipWriterStream()
zipper.readable.pipeTo((await Deno.create('Archive.zip')).writable)
readable1.pipeTo(zipper.writable('numbers.txt'))
readable2.pipeTo(zipper.writable('letters.txt'))
zipper.close()

Constructors

Properties

Methods

Constructors

Properties

readable: ReadableStream<Uint8Array>

The readable stream.

zipWriter: ZipWriter<unknown>

The ZipWriter property.

Methods

  • Writes the entries directory, writes the global comment, and returns the content of the zipped file.

    Parameters

    • Optional comment: Uint8Array

      The global comment of the zip file.

    • Optional options: ZipWriterCloseOptions

      The options.

    Returns Promise<unknown>

    The content of the zip file.

  • Returns an object containing a readable and writable property for the .pipeThrough method

    Type Parameters

    • T

    Parameters

    • path: string

      The name of the stream when unzipped.

    Returns {
        readable: ReadableStream<T>;
        writable: WritableStream<T>;
    }

    An object containing readable and writable properties

    • readable: ReadableStream<T>
    • writable: WritableStream<T>
  • Returns a WritableStream for the .pipeTo method

    Type Parameters

    • T

    Parameters

    • path: string

      The directory path of where the stream should exist in the zipped stream.

    Returns WritableStream<T>

    A WritableStream.