Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zipreaderstream example #510

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,15 +629,21 @@ export class Uint8ArrayWriter extends Writer<Uint8Array> { }
* Represents an instance used to create an unzipped stream.
*
* @example
* This example will take a zip file, decompress it and then recompress each file in it, saving it to disk.
* This example will take a zip file, decompress it and then save its files and directories to disk.
* ```
* for await (const entry of (await fetch(urlToZippedFile)).body.pipeThrough(new ZipWriterStream()))
* if (entry.readable) {
* console.log(entry.filename)
* entry.readable
* .pipeThrough(ZipReaderStream().transform(entry.filename))
* .pipeTo((await Deno.create(entry.filename + '.zip')).writable)
* import {resolve} from "https://deno.land/std/path/mod.ts";
* import {ensureDir, ensureFile} from "https://deno.land/std/fs/mod.ts";
*
* for await (const entry of (await fetch(urlToZippedFile)).body.pipeThrough(new ZipReaderStream())) {
* const fullPath = resolve(destination, entry.filename);
* if (entry.directory) {
* await ensureDir(fullPath);
* continue;
* }
*
* await ensureFile(fullPath);
* await entry.readable?.pipeTo((await Deno.create(fullPath)).writable);
* }
* ```
*/
export class ZipReaderStream<T> {
Expand Down