joinMappings
joinMappings<
K,V>(maps,resolveConflict):Map<K,V>
Defined in: packages/core/src/map/join-mappings.ts:32
Merges several maps into one, resolving repeated keys with a stated rule.
resolveConflict is required rather than defaulted, because the default
everyone reaches for — new Map([...a, ...b]) — silently keeps the last
write, and a silent default is the bug this exists to prevent. Pass (_key, _existing, incoming) => incoming to ask for it deliberately.
Insertion order follows first appearance: a key repeated in a later map keeps the position it was first given, only its value changes.
Time complexity: O(total entries).
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”Iterable<ReadonlyMap<K, V>>
The maps to merge, in precedence order.
resolveConflict
Section titled “resolveConflict”MappingConflictResolver<K, V>
Called once per repeated key, with the accumulated value and the incoming one.
Returns
Section titled “Returns”Map<K, V>
A new map. The inputs are not modified.