Last active
February 13, 2021 21:54
-
-
Save gildas-lormeau/3758e4028f277459f285a53269e7e64a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((zipV2) => { | |
window.zip = { | |
set useWebWorkers(value) { | |
zipV2.configure({ useWebWorkers: value }); | |
}, | |
createWriter(writer, callback, onWriterError) { | |
const zipWriter = new zipV2.ZipWriter(writer); | |
callback({ | |
add(name, reader, onend, onerror) { | |
zipWriter.add(name, reader).then(onend).catch(onerror).catch(onWriterError); | |
}, | |
close(onend, onerror) { | |
zipWriter.close().then(onend).catch(onerror).catch(onWriterError); | |
} | |
}); | |
}, | |
createReader(reader, callback, onReaderError) { | |
const zipReader = new zipV2.ZipReader(reader); | |
callback({ | |
getEntries(onend, onerror) { | |
zipReader.getEntries().then(entries => { | |
onend(entries.map(entry => { | |
const entryV2 = entry; | |
entry = { | |
filename: entryV2.filename, | |
directory: entryV2.directory, | |
compressedSize: entryV2.compressedSize, | |
uncompressedSize: entryV2.uncompressedSize, | |
lastModDate: entryV2.lastModDate, | |
lastModDateRaw: entryV2.rawLastModDate, | |
comment: entryV2.comment, | |
crc32: entryV2.signature, | |
getData(writer, onend, onerror) { | |
entryV2.getData(writer).then(onend).catch(onerror).catch(onReaderError); | |
} | |
}; | |
return entry; | |
})); | |
}).catch(onerror).catch(onReaderError); | |
}, | |
close(onend, onerror) { | |
zipReader.close().then(onend).catch(onerror).catch(onReaderError); | |
} | |
}); | |
}, | |
getMimeType() { | |
return zipV2.getMimeType(); | |
}, | |
BlobWriter: zipV2.BlobWriter, | |
BlobReader: zipV2.BlobReader, | |
Data64URIWriter: zipV2.Data64URIWriter, | |
Data64URIReader: zipV2.Data64URIReader, | |
TextWriter: zipV2.TextWriter, | |
TextReader: zipV2.TextReader, | |
HttpReader: : zipV2.HttpReader, | |
HttpRangeReader: : zipV2.HttpRangeReader | |
}; | |
})(zip); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment