A replacement for gleam_crypto that works on all targets.

use copy to prentend javascript hash object is immutable #2

targeting main from bird-dancer.tngl.sh/munch:main
Open opened by and assigned to bird-dancer.tngl.sh
targeting main from bird-dancer.tngl.sh/munch:main

addresses #1

use hash.copy to copy hash object before update and digest, making it reusable. Every JS runtime I looked at, that supports hash.digest and hash.update, also support hash.copy.

This holds a slight performance penalty, where doing 20 updates takes around 0.01ms longer. However the slowdown is just relative to the number of calls and not to the size of each string/hash object.

If you find this to be a problem, this could be mostly mitigated by collecting in a list per update chain and only calling copy in finish and when the pending collection reaches a certain size.

Commits 3

fallback to pure gleam implementation if js runtime doesn't have hash.copy
add test for updating and using digest from the 'same' hash start
js native: copy hash object in `update` and `finish` so it can be used multiple times