-
Notifications
You must be signed in to change notification settings - Fork 39
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
Revised compress method #1
base: master
Are you sure you want to change the base?
Conversation
Instead of throwing an error or zero-padding, "compress" now returns the input bytes if there are less than or equal to "target" number of them. I think this is logical since the goal of compress is to reduce the complexity of the digest before making it human consumable. In this case the complexity is already low enough to proceed.
Excess bytes are now distributed amongst the compressed bytes, instead of being dumped into the final bit as they were before.
Happy to resurrect this! Compression method comments are added. Why is this better? For example: compress_old([123,456,798,147], 4)
# -> [123, 456, 789, 147]
compress_old([123,456,789,147,258,369,321],4)
# -> [123, 456, 789, 417] (only the last byte has changed)
compress_new([123,456,798,147], 4)
# -> [123, 456, 789, 147]
compress_new([123,456,789,147,258,369,321],4)
# -> [435, 902, 115, 321] (all 4 bytes have changed) As an aside, I have an equivalent compress method prepared for the Javascript port and I will create a pull request there if this is merged. Thanks! |
I'm maintaining the |
I made 2 changes to the "compress" method: