You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried using some Files (obtained from the files attribute of input type="file") as keys in a Dict but despite inserting multiple different files there was only one entry at the end. Turns out they're all considered the same key. typeof file returns "object" which means we go to hashObject. I think it ends up in the else case:
The issue is that Object.keys returns [] for all files.
It seems that if it went through hashByReference it might work but not sure how to resolve this more generally. I also note that hashObject does a check for a hashCode function. I suppose another option, at least for my project would be to add that to the Fileprototype or wrap them in a class that does. 🤔
Edit: As a workaround I might be about to use the value returned from URL.createObjectURL(object) as the key instead.
I tried using some Files (obtained from the files attribute of
input type="file"
) as keys in aDict
but despite inserting multiple different files there was only one entry at the end. Turns out they're all considered the same key.typeof file
returns"object"
which means we go tohashObject
. I think it ends up in theelse
case:stdlib/src/dict.mjs
Lines 106 to 113 in 6a701d1
The issue is that
Object.keys
returns[]
for all files.It seems that if it went through
hashByReference
it might work but not sure how to resolve this more generally. I also note thathashObject
does a check for ahashCode
function. I suppose another option, at least for my project would be to add that to theFile
prototype
or wrap them in a class that does. 🤔Edit: As a workaround I might be about to use the value returned from URL.createObjectURL(object) as the key instead.
Gleam version: gleam 1.0.0-rc2
Target: javascript
Env: browser
The text was updated successfully, but these errors were encountered: