streaming zip archiver/extractor jsr.io/@mary/zip
typescript jsr
1# zip 2 3[JSR](https://jsr.io/@mary/zip) | [source code](https://tangled.sh/@mary.my.id/pkg-zip) 4 5streaming zip archiver/extractor 6 7```ts 8import { unzip, zip } from '@mary/zip'; 9import { fromFsFile } from '@mary/zip/deno'; 10 11// creating an archive 12{ 13 const stream = ReadableStream.from( 14 zip([ 15 { filename: 'README.md', data: `Hello, **world**!\n` }, 16 { filename: 'mod.ts', data: `console.log("Hello");\n` }, 17 ]), 18 ); 19 20 await Deno.writeFile('./archive.zip', stream); 21} 22 23// extracting a specific file from an archive 24{ 25 using file = await Deno.open('./archive.zip'); 26 const reader = await fromFsFile(file); 27 28 for await (const entry of unzip(reader)) { 29 console.log(entry.filename, entry.size); 30 31 if (entry.filename === 'mod.ts') { 32 console.log(await entry.text()); 33 } 34 } 35} 36```