mini-hamt
mini-hamt copied to clipboard
Getting keys
It'd be nice to have a way to find out what keys are present in a tree:
data = hamt.empty
data = hamt.set(data, 'a', 'hello')
data = hamt.set(data, 'b', 'world')
hamt.keys(data) // => ['a', 'b']
a length
function would be nice too!
Ah, ya. We could do something like that. If you're extracting keys, you may also want to be able to map over things efficiently (right now you could only do that by explicitly hamt.set
ting each key, but if hamt implements this internally, you could just do one set but rewrite all the values mutatively - much faster).
Hi @ashaffer, I don't know if you're still maintaining this library; I was hoping to use it as a dependency for my library Recoil, but it would need iteration over keys. Is that something you'd be interested in adding? I did some benchmarking and found Mini-HAMT to be not only the smallest but also the fastest standalone HAMT implementation for basic get and set operations on maps of all sizes.