Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added gunzip, zlib decompression support and revamped API #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

101arrowz
Copy link

@101arrowz 101arrowz commented Mar 26, 2020

I added basic support for zlib and gzip input (little validation - focused on performance and file size), as well as autodetection of format. This makes the API a lot easier to use for those with zlib/gzip data. I also added JSDoc and type annotations for the methods, which allows for better autocomplete and TypeScript support.

Possibly most importantly of all, I made the second parameter (the output array) optional, so that those without knowledge of the output size can still use this awesome library. It will automatically use an (admittedly inefficient) standard array to store the result of the decompression before switching to a Uint8Array. If the data is gzipped, a header tells us the output file size, so we use that to maximize memory efficiency. The new API is still 100% compatible with the old API.

Thanks for creating this wonderful library!

@101arrowz
Copy link
Author

@devongovett Do you think this is in scope for the project? If not, let me know, and I'll make a fork and publish my own NPM package with the changes.

@101arrowz
Copy link
Author

It's been a few months so I would like to know your opinion @devongovett. I'm currently using this PR in a project but would like to use the NPM package.

@101arrowz
Copy link
Author

I've now created my own tool fflate that is much faster than this library (and even pako), supports compression, but is about 3.5kB minified and 2kB gzipped when using tree shaking to use only the decompression API. I'll leave this PR open in case you decide to use it, but for anyone looking for a tiny compression/decompression library, I would suggest using fflate instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant