javascript-collections-framework
    Preparing search index...

    Interface HashMapOptions<K>

    Options for a HashMap, about its keys. At most one of key and equivalence may be given; with neither, keys compare with SameValueZero, as in native Map.

    const byId: HashMapOptions<{ id: number }> = { key: (user) => user.id }
    const byValue: HashMapOptions<Point> = { equivalence: valueEquivalence }
    interface HashMapOptions<K> {
        equivalence?: Equivalence<K>;
        key?: KeyOf<K>;
    }

    Type Parameters

    • K
    Index
    equivalence?: Equivalence<K>

    Decides key equality by its equals and hash. valueEquivalence honours the equalsSymbol/hashCodeSymbol protocol; sameValueZeroEquivalence is the default behaviour.

    key?: KeyOf<K>

    Derives the primitive key a key is found by; two keys are the same key when their derived keys are SameValueZero-equal. Called once per key per operation, never again for a stored key.