MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / ZipFileWriter

Class ZipFileWriter

packages/filesystem/zip/rw.ts:16–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16export class ZipFileWriter implements FileWriter {
17 zip: JSZipFile;
18
19 path: string;
20
21 modifiedDate: number | undefined;
22
23 constructor(zip: JSZipFile, path: string, opts?: FileCreateOptions) {
24 this.zip = zip;
25 this.path = path;
26 if (opts && opts.modifiedDate) {
27 this.modifiedDate = opts.modifiedDate;
28 }
29 }
30
31 async write(content: string | Blob): Promise<void> {
32 const opts = {} as JSZipFileOptions;
33 if (this.modifiedDate) {
34 opts.date = new Date(this.modifiedDate);
35 // jszipp does not require timezone adjustment to UTC Date
36 }
37 const fileData = typeof content === "string" ? content : new Uint8Array(await content.arrayBuffer());
38 this.zip.file(this.path, fileData, opts);
39 }
40}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected