mattbierner / hamt

Javascript Hash Array Mapped Trie
MIT License
250 stars 16 forks source link

nested hash tables #6

Closed rstacruz closed 8 years ago

rstacruz commented 8 years ago

Is it possible to represent this data structure as a HAMT tree?

data =
  { users:
    { 1: { email: 'homer@simpson.com', publisher: true },
      2: { email: 'marge@simpson.com' } },
    posts:
    { 1: { author_id: 1, title: 'How to eat donuts' },
      2: { author_id: 1, title: 'Managing nuclear reactors' } } }
mattbierner commented 8 years ago

You should be able to store any value, including other hash tables and null, within the map. Is there a specific issue you are running into?

rstacruz commented 8 years ago

nothing in particular, i just wanted to see if i can use it to manage a big nested structure without having to nest hashes (or nest hamt objects?) :)

mattbierner commented 8 years ago

Glad to hear that. Just one thing to consider is that for very small objects, immutability by copying JavaScript objects will be quicker than using a full immutable data structure. Try profiling the expected work load to see which is more appropriate.