| 14 | } |
| 15 | |
| 16 | export 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected