mini-hamt icon indicating copy to clipboard operation
mini-hamt copied to clipboard

Getting keys

Open rstacruz opened this issue 8 years ago • 2 comments

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!

rstacruz avatar May 29 '16 12:05 rstacruz

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).

ashaffer avatar May 29 '16 19:05 ashaffer

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.

davidmccabe avatar Dec 11 '20 01:12 davidmccabe