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

Add an option to set the DEFLATE level. #201

Merged
merged 2 commits into from Feb 20, 2015

Conversation

Projects
None yet
2 participants
@dduponchel
Copy link
Collaborator

dduponchel commented Feb 18, 2015

This commit adds a new option, compressionOptions. If it contains a field
level, it is used by the DEFLATE compression to set the compression level :
6 by default or any level between 1 (best speed) and 9 (best compression).

Fix #165.

Add an option to set the DEFLATE level.
This commit adds a new option, `compressionOptions`. If it contains a field
`level`, it is used by the DEFLATE compression to set the compression level :
6 by default or any level between 1 (best speed) and 9 (best compression).

Fix #165.
Note : if the entry is *already* compressed (coming from a compressed zip file),
calling `generate()` with a different compression level won't update the entry.
The reason is simple : JSZip doesn't know how was compressed the content and
how to match the compression level with the implementation we use.

This comment has been minimized.

@Stuk

Stuk Feb 19, 2015

Owner

Grammar: "...doesn't know how compressed the content was and how to..."

This comment has been minimized.

@dduponchel

dduponchel Feb 19, 2015

Collaborator

Fixed.

return pako.deflateRaw(input);
exports.compress = function(input, compressionOptions) {
return pako.deflateRaw(input, {
level : compressionOptions.level || -1 // default compression

This comment has been minimized.

@Stuk

Stuk Feb 19, 2015

Owner

Is there a risk of compressionOptions being undefined?

This comment has been minimized.

@dduponchel
@Stuk

This comment has been minimized.

Copy link
Owner

Stuk commented Feb 19, 2015

Otherwise looks good 👍

Stuk added a commit that referenced this pull request Feb 20, 2015

Merge pull request #201 from dduponchel/deflate_level
Add an option to set the DEFLATE level.

@Stuk Stuk merged commit d329558 into Stuk:master Feb 20, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@dduponchel dduponchel deleted the dduponchel:deflate_level branch Feb 20, 2015

@dduponchel dduponchel referenced this pull request Mar 10, 2015

Merged

Release v2.5.0 #206

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment