MCPcopy Create free account
hub / github.com/Effect-TS/effect / merge

Function merge

packages/cli/src/internal/options.ts:2023–2037  ·  view source on GitHub ↗
(
  map1: HashMap.HashMap<string, ReadonlyArray<string>>,
  map2: ReadonlyArray<[string, ReadonlyArray<string>]>
)

Source from the content-addressed store, hash-verified

2021 * Sums the list associated with the same key.
2022 */
2023const merge = (
2024 map1: HashMap.HashMap<string, ReadonlyArray<string>>,
2025 map2: ReadonlyArray<[string, ReadonlyArray<string>]>
2026): HashMap.HashMap<string, ReadonlyArray<string>> => {
2027 if (Arr.isNonEmptyReadonlyArray(map2)) {
2028 const head = Arr.headNonEmpty(map2)
2029 const tail = Arr.tailNonEmpty(map2)
2030 const newMap = Option.match(HashMap.get(map1, head[0]), {
2031 onNone: () => HashMap.set(map1, head[0], head[1]),
2032 onSome: (elems) => HashMap.set(map1, head[0], Arr.appendAll(elems, head[1]))
2033 })
2034 return merge(newMap, tail)
2035 }
2036 return map1
2037}
2038
2039// =============================================================================
2040// Completion Internals

Callers 2

matchOptionsFunction · 0.70
matchUnclusteredFunction · 0.70

Calls 2

getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected