MCPcopy
hub / github.com/Effect-TS/effect / merge

Function merge

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

Source from the content-addressed store, hash-verified

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

Callers 2

matchOptionsFunction · 0.70
matchUnclusteredFunction · 0.70

Calls 2

getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected