Hyperlinkv0.8.0-beta.28

HashMap

HashMap.unionconsteffect/HashMap.ts:912
<K1, V1>(that: HashMap<K1, V1>): <K0, V0>(
  self: HashMap<K0, V0>
) => HashMap<K1 | K0, V1 | V0>
<K0, V0, K1, V1>(self: HashMap<K0, V0>, that: HashMap<K1, V1>): HashMap<
  K0 | K1,
  V0 | V1
>

Combines two HashMaps into one.

Details

Entries from that are inserted into self; when both maps contain an equal key, the value from that replaces the value from self.

Example (Combining HashMaps)

import { HashMap } from "effect"

const map1 = HashMap.make(["a", 1], ["b", 2])
const map2 = HashMap.make(["b", 20], ["c", 3])
const union = HashMap.union(map1, map2)

console.log(HashMap.size(union)) // 3
console.log(HashMap.get(union, "b")) // Option.some(20) - map2 wins
combining
Source effect/HashMap.ts:9124 lines
export const union: {
  <K1, V1>(that: HashMap<K1, V1>): <K0, V0>(self: HashMap<K0, V0>) => HashMap<K1 | K0, V1 | V0>
  <K0, V0, K1, V1>(self: HashMap<K0, V0>, that: HashMap<K1, V1>): HashMap<K0 | K1, V0 | V1>
} = internal.union
Referenced by 1 symbols