Open AlexanderOMara opened 5 years ago
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.
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 foraddBuffer
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?