File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -629,15 +629,21 @@ export class Uint8ArrayWriter extends Writer<Uint8Array> { }
629
629
* Represents an instance used to create an unzipped stream.
630
630
*
631
631
* @example
632
- * This example will take a zip file, decompress it and then recompress each file in it, saving it to disk.
632
+ * This example will take a zip file, decompress it and then save its files and directories to disk.
633
633
* ```
634
- * for await (const entry of (await fetch(urlToZippedFile)).body.pipeThrough(new ZipWriterStream()))
635
- * if (entry.readable) {
636
- * console.log(entry.filename)
637
- * entry.readable
638
- * .pipeThrough(ZipReaderStream().transform(entry.filename))
639
- * .pipeTo((await Deno.create(entry.filename + '.zip')).writable)
634
+ * import {resolve} from "https://deno.land/std/path/mod.ts";
635
+ * import {ensureDir, ensureFile} from "https://deno.land/std/fs/mod.ts";
636
+ *
637
+ * for await (const entry of (await fetch(urlToZippedFile)).body.pipeThrough(new ZipReaderStream()))) {
638
+ * const fullPath = resolve(destination, entry.filename);
639
+ * if (entry.directory) {
640
+ * await ensureDir(fullPath);
641
+ * continue;
640
642
* }
643
+ *
644
+ * await ensureFile(fullPath);
645
+ * await entry.readable?.pipeTo((await Deno.create(fullPath)).writable);
646
+ * }
641
647
* ```
642
648
*/
643
649
export class ZipReaderStream < T > {
You can’t perform that action at this time.
0 commit comments