-
Notifications
You must be signed in to change notification settings - Fork 0
/
_test.ts
30 lines (25 loc) · 942 Bytes
/
_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { get_entries, compress, create_zip, open_zip } from "./mod.ts";
// // compression
const zip = await compress('test/', 'test.zip');
//extract. functional, but under development.
const file = await Deno.open('test.zip');
await Deno.mkdir('result');
for (const { filename, index, extract } of get_entries(file)) {
const file = await Deno.create('result/' + filename);
const content = await extract();
file.writeSync(content);
}
// increment file compression
const test = await create_zip('test.zip');
await test.push(new TextEncoder().encode('Hello World'), 'hello.txt');
await test.close();
// edit file
const {insert, remove, entries, close} = await open_zip('test.zip');
console.log(entries());
await insert(await Deno.open('icon.png'),'icon3.png');
console.log(entries());
await insert(await Deno.open('icon.png'),'icon.png');
console.log(entries());
await remove('icon3.png');
console.log(entries());
await close();