23 lines · 694 B · TypeScript
RawDownload
import * as P from "effect/Predicate"; export type DeepPartial<T> = T extends readonly (infer U)[]  ? readonly DeepPartial<U>[]  : T extends object    ? { [K in keyof T]?: DeepPartial<T[K]> }    : T; export function deepMerge<T extends Record<string, unknown>>(current: T, patch: DeepPartial<T>): T {  if (!P.isObject(current) || !P.isObject(patch)) {    return patch as T;  }   const next = { ...current } as Record<string, unknown>;  for (const [key, value] of Object.entries(patch)) {    if (value === undefined) continue;     const existing = next[key];    next[key] = P.isObject(existing) && P.isObject(value) ? deepMerge(existing, value) : value;  }   return next as T;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t