ashaffer / mini-hamt

18 stars 0 forks source link

Getting keys #2

Open rstacruz opened 8 years ago

rstacruz commented 8 years ago

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!

ashaffer commented 8 years ago

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.setting each key, but if hamt implements this internally, you could just do one set but rewrite all the values mutatively - much faster).

davidmccabe commented 3 years ago

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.