Is there a hashmap library for JavaScript?

后端 未结 8 1757
抹茶落季
抹茶落季 2021-02-14 10:35

In JavaScript, all Objects act a bit like hashmaps. However, the keys to these hashmaps must be strings. If they\'re not, they\'re converted with toString(). Tha

8条回答
  •  遥遥无期
    2021-02-14 11:06

    jOrder could be modified to treat objects with the same properties (but in different order) as identical when performing an index lookup.

    If you have the object {bar: 2, baz: 3, val: 200} in your list, and you've previously put a fitting index on a jOrder table like this:

    var table = jOrder(data)
        .index('signature', ['bar', 'baz'], {grouped: true});
    

    Then right now table.where([{bar: 2, baz: 3}])[0].val will return 200, but table.where([{baz: 3, bar: 2}])[0].val won't. It wouldn't take much effort though to make it not depend on the order of properties. Let me know if you're interested and I'll push the fix to GitHub as soon as I can.

提交回复
热议问题