Effect CommunityEC
Effect Community•2y ago•
15 replies
Aldwin

Choosing the Right Data Structure for Numeric Keys in JavaScript

What data structure do I use if I "just" want a Record with numeric (integer) keys?

I tried a sparse Array but it's a headache (Array length is not updated accordingly when using Array.replace and friends), I tried native Map but there don't seem to be immutable utilities for it in Effect, I tried HashMap but what's all that stuff about hashes? (makes me feel it's not the right tool) 😓 I could cast my numbers to String and use a plain Record, but then I need to parse them back to numbers in another part of the code (information is lost). Is there anything out there for me?
Was this page helpful?