MCPcopy
hub / github.com/poooi/poi / mergeConfig

Function mergeConfig

lib/utils.ts:53–69  ·  view source on GitHub ↗
(defaults: object, incoming: object)

Source from the content-addressed store, hash-verified

51 * @param incoming loaded config
52 */
53export const mergeConfig = (defaults: object, incoming: object) => {
54 const overwrite: object = mapValues(defaults, (value, key) => {
55 if (isPlainObject(value)) {
56 return mergeConfig(value, get(incoming, key))
57 }
58
59 const incomingValue = get(incoming, key)
60
61 return [isNumber, isArray, isString, isBoolean].some(
62 (test) => test(value) !== test(incomingValue),
63 )
64 ? value
65 : incomingValue
66 })
67
68 return isPlainObject(incoming) ? { ...incoming, ...overwrite } : overwrite
69}

Callers 2

constructorMethod · 0.90
utils.sepc.tsFile · 0.90

Calls 1

testFunction · 0.85

Tested by

no test coverage detected