photopea / UZIP.js

Simple ZIPping library for Javascript
MIT License
187 stars 27 forks source link

es6 module version #9

Closed greggman closed 5 years ago

greggman commented 5 years ago

just fyi, i posted a es6 module based version of your library here

https://github.com/greggman/uzip-module

I hope that's okay. I'm happy to take it down or transfer it to you if you want.

photopea commented 5 years ago

Hey, that sounds great, thanks!

I still wonder, why some JS ZIP libraries are 10x larger than UZIP, while they do the same thing: https://github.com/Stuk/jszip

SheetJSDev commented 5 years ago

Is the module version needed? The NPM module (which is now pulling the exact code) can be used in bundlers like parcel and webpack, https://codesandbox.io/s/fancy-fog-1xfy9 is a live example.

greggman commented 5 years ago

And if I don't want to use a bundler? Also how about tree shaking? (note I have not finished make the code shakable)

photopea commented 5 years ago

Hi, thanks for makinga fork of UZIP.js ! BTW. I updated it yesterday, so you might want to update it, too.

greggman commented 5 years ago

Thanks for the heads up about the update. Do you have a zip file that failed before the change? I'd like to add a test

photopea commented 5 years ago

For each file, the ZIP stores both the size of compressed and original file. So it never failed for ZIP files.

But in many cases, (e.g. PDF files) ZLIB compression is used without knowing the size of decompressed data. So it is tricky to estimate how long array is needed for the output.

In the latest version, for each byte written to the output, it checks, if it will fit into the array, and if not, a bigger array is created and the content of the old array is copied into it.

TomasHubelbauer commented 3 years ago

For anyone who lands here looking for an ESM version of UZIP, I maintain one over here: https://github.com/TomasHubelbauer/esm-uzip-js