import { ZipWriterStream } from "https://dotland.deno.dev/x/zipjs@v2.7.42/index.d.ts";
Represents an instance used to create a zipped stream.
Examples
This example creates a zipped file called numbers.txt.zip containing the numbers 0 - 1000 each on their own line.
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)
This example creates a zipped file called Archive.zip containing two files called numbers.txt and letters.txt
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()
Methods
close(comment?: Uint8Array, options?: ZipWriterCloseOptions): Promise<unknown>
Writes the entries directory, writes the global comment, and returns the content of the zipped file.
transform<T>(path: string): { readable: ReadableStream<T>; writable: WritableStream<T>; }
Returns an object containing a readable and writable property for the .pipeThrough method