streaming zip archiver/extractor jsr.io/@mary/zip
typescript jsr

docs: fix example

mary.my.id e491a462 30736ba4

verified
Changed files
+10 -4
+10 -4
README.md
··· 8 8 import { unzip, zip } from '@mary/zip'; 9 9 import { fromFsFile } from '@mary/zip/deno'; 10 10 11 + // creating an archive 11 12 { 12 - const iterable = ReadableStream.from( 13 + const stream = ReadableStream.from( 13 14 zip([ 14 - { name: 'README.md', data: `Hello, **world**!\n` }, 15 - { name: 'mod.ts', data: `console.log("Hello");\n` }, 15 + { filename: 'README.md', data: `Hello, **world**!\n` }, 16 + { filename: 'mod.ts', data: `console.log("Hello");\n` }, 16 17 ]), 17 18 ); 18 19 19 - // ... 20 + await Deno.writeFile('./archive.zip', stream); 20 21 } 21 22 23 + // extracting a specific file from an archive 22 24 { 23 25 using file = await Deno.open('./archive.zip'); 24 26 const reader = await fromFsFile(file); 25 27 26 28 for await (const entry of unzip(reader)) { 27 29 console.log(entry.filename, entry.size); 30 + 31 + if (entry.filename === 'mod.ts') { 32 + console.log(await entry.text()); 33 + } 28 34 } 29 35 } 30 36 ```