deepMerge
deepMerge<
T>(base,override):T
Defined in: merge.ts:22
Deep-merge two values, vite-style:
- plain objects merge recursively
- arrays concatenate (
basefirst, thenoverride) - an
undefinedvalue inoverrideis skipped (keepsbase) - every other
overridevalue replacesbase
Neither input is mutated.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”T
override
Section titled “override”unknown
Returns
Section titled “Returns”T
Example
Section titled “Example”import { deepMerge } from "@theholocron/object-utils";
deepMerge({ a: 1, nested: { x: 1 } }, { nested: { y: 2 } });// { a: 1, nested: { x: 1, y: 2 } }
deepMerge({ tasks: ["a"] }, { tasks: ["b"] });// { tasks: ["a", "b"] }