MCPcopy Create free account
hub / github.com/contentlayerdev/contentlayer / mergeDeep

Function mergeDeep

packages/@contentlayer/utils/src/object/index.ts:14–28  ·  view source on GitHub ↗
(...objs: T[])

Source from the content-addressed store, hash-verified

12}
13
14export const mergeDeep = <T extends Record<any, any>>(...objs: T[]): T => {
15 const result = {} as T
16 for (const obj of objs) {
17 for (const [key, val] of Object.entries(obj)) {
18 if (val && typeof val === 'object' && !Array.isArray(val)) {
19 // @ts-expect-error TODO
20 result[key] = mergeDeep(result[key] || {}, val)
21 } else {
22 // @ts-expect-error TODO
23 result[key] = val
24 }
25 }
26 }
27 return result
28}
29
30export type PartialDeep<T> = {
31 [P in keyof T]?: T[P] extends Record<any, any> ? PartialDeep<T[P]> : T[P]

Callers 2

patchDocumentTypeFunction · 0.90
patchNestedTypeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…