gildas-lormeau / zip.js

JavaScript library to zip and unzip files supporting multi-core compression, compression streams, zip64, split files and encryption.
https://gildas-lormeau.github.io/zip.js
BSD 3-Clause "New" or "Revised" License
3.38k stars 510 forks source link

Expose exportZip on ZipDirectoryEntry #381

Closed Wintermoose closed 1 year ago

Wintermoose commented 1 year ago

Hi,

Would it be possible to expose the exportZip method on ZipDirectoryEntry, in the typescript declaration file? Or is there a reason why this isn't done (like it's not considered stable)? We're using this (excellent!) library for excel file creation, and for that we need to specify the mime type (or create another blob from the output blob), but the otherwise useful wrappers (exportBlob etc) don't expose a way to set it, so we have to go through exportZip( new BlobWriter(mime), ...)

Alternatively, adding the option to specify it directly in the export* helpers would be of course great, but that means changing the api (new parameter, or new entry in options)

gildas-lormeau commented 1 year ago

Thank you for the suggestions. I had decided not to expose exportZip because I was not sure it would be useful. However, your example shows there's a need especially when using custom Writer implementations, where the parameters to pass to the constructor are unknown by zip.js.

In the end, I decided to implement both of your suggestions :)

Wintermoose commented 1 year ago

Thank you, that was really unexpectedly fast (before my code with a workaround went through PR...)

Just a small suggestion - you might want to make the mimeType optional.

gildas-lormeau commented 1 year ago

Yes... I will fix this :p

gildas-lormeau commented 1 year ago

And it's officially released as v2.6.56 :)