• Merges two Maps by adding all entries from the second Map into the first Map. If a key exists in both Maps, either applies a merge function to combine the values or uses the value from the second Map if no merge function is provided.

    Type Parameters

    • K

      The type of keys in both Maps

    • V

      The type of values in both Maps

    Parameters

    • map: Map<K, V>

      The target Map that will be modified and returned

    • other: Map<K, V>

      The source Map whose entries will be merged into the target Map

    • Optional mergeFn: ((v1, v2) => V)

      Optional function to combine values when the same key exists in both Maps. Receives the value from the target Map as the first argument and the value from the source Map as the second argument.

        • (v1, v2): V
        • Parameters

          • v1: V
          • v2: V

          Returns V

    Returns Map<K, V>

    The modified target Map with all entries merged (note: modifies the original Map)