From 7af44a75572f0758faee16ea8705d0fa9b85848a Mon Sep 17 00:00:00 2001 From: Jesper van den Ende Date: Thu, 2 May 2024 23:24:08 +0200 Subject: [PATCH 1/2] update ZipReaderStream example --- index.d.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/index.d.ts b/index.d.ts index 5c9b5916..bbf6533c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -629,15 +629,21 @@ export class Uint8ArrayWriter extends Writer { } * 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 { From b41e1c2a96212332a37feafa937e4ffa27c6d069 Mon Sep 17 00:00:00 2001 From: Jesper van den Ende Date: Thu, 2 May 2024 23:32:27 +0200 Subject: [PATCH 2/2] fix syntax error --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index bbf6533c..c4a56924 100644 --- a/index.d.ts +++ b/index.d.ts @@ -634,7 +634,7 @@ export class Uint8ArrayWriter extends Writer { } * 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()))) { + * for await (const entry of (await fetch(urlToZippedFile)).body.pipeThrough(new ZipReaderStream())) { * const fullPath = resolve(destination, entry.filename); * if (entry.directory) { * await ensureDir(fullPath);