diff --git a/packages/endo/src/zip.js b/packages/endo/src/zip.js new file mode 100644 index 0000000000..fddc3cc275 --- /dev/null +++ b/packages/endo/src/zip.js @@ -0,0 +1,17 @@ +// Decouples Endo's usage from JSZip's particular presentation. + +import JSZip from "jszip"; + +export const readZip = async data => { + const zip = new JSZip(); + await zip.loadAsync(data); + const read = async path => zip.file(path).async("uint8array"); + return { read }; +}; + +export const writeZip = () => { + const zip = new JSZip(); + const write = async (path, data) => zip.file(path, data); + const data = async () => zip.generateAsync({ type: "uint8array" }); + return { write, data }; +};