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

Option for addBuffer to compress if smaller? #54

Open
AlexanderOMara opened this issue Aug 15, 2019 · 1 comment
Open

Option for addBuffer to compress if smaller? #54

AlexanderOMara opened this issue Aug 15, 2019 · 1 comment

Comments

@AlexanderOMara
Copy link

AlexanderOMara commented Aug 15, 2019

It would be nice to have an option to have addBuffer compress the buffer if that makes the resulting file smaller.

I'm not sure it would really work for addFile but it would for addBuffer because the entire buffer is available at once.

I can make the pull request if the API can be decided on. Maybe one of the following?

addBuffer(buffer, path, {
    compress: null
});
addBuffer(buffer, path, {
    compress: 'auto'
});
addBuffer(buffer, path, {
    compress: 'smaller'
});
@thejoshwolfe
Copy link
Owner

Hi @AlexanderOMara sorry for the delayed response.

What you're suggesting is very reasonable, and easy to implement for addBuffer(). However, I'm concerned that this is such a useful feature that it would probably be desirable in general, which puts an awkward incentive for users of this API to use addBuffer() for everything, arguably the least performant way to add files.

I'm interested in coming up with a way to automatically enable/disable compression for all of the add*() APIs rather than just for addBuffer(). Perhaps a small buffer of initial bytes could be previewed and tested through compression to see if it yields a promising ratio, and then the full stream could be processed after that? That would introduce significant complexity to the stream management, which I'm already a little uncertain about with the node stdlib.

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

No branches or pull requests

2 participants