Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fathym_common/src/src.deps.ts>deepMerge

The Fathym Reference Architecture provides the common foundation for applications built in Typescript.
Go to Latest
function deepMerge
Re-export
import { deepMerge } from "https://deno.land/x/fathym_common@v0.0.143/src/src.deps.ts";

Merges the two given Records, recursively merging any nested Records with the second collection overriding the first in case of conflict

For arrays, maps and sets, a merging strategy can be specified to either replace values, or merge them instead. Use includeNonEnumerable option to include non-enumerable properties too.

Examples

Example 1

import { deepMerge } from "https://deno.land/std@0.224.0/collections/deep_merge.ts";
import { assertEquals } from "https://deno.land/std@0.224.0/assert/assert_equals.ts";

const a = { foo: true };
const b = { foo: { bar: true } };

assertEquals(deepMerge(a, b), { foo: { bar: true } });

Type Parameters

T extends Record<PropertyKey, unknown>

Parameters

record: Partial<Readonly<T>>
other: Partial<Readonly<T>>
optional
options: Readonly<DeepMergeOptions>

Merges the two given Records, recursively merging any nested Records with the second collection overriding the first in case of conflict

For arrays, maps and sets, a merging strategy can be specified to either replace values, or merge them instead. Use includeNonEnumerable option to include non-enumerable properties too.

Examples

Example 1

import { deepMerge } from "https://deno.land/std@0.224.0/collections/deep_merge.ts";
import { assertEquals } from "https://deno.land/std@0.224.0/assert/assert_equals.ts";

const a = { foo: true };
const b = { foo: { bar: true } };

assertEquals(deepMerge(a, b), { foo: { bar: true } });

Type Parameters

T extends Record<PropertyKey, unknown>
U extends Record<PropertyKey, unknown>
Options extends DeepMergeOptions

Parameters

record: Readonly<T>
other: Readonly<U>
optional
options: Readonly<Options>

Returns

DeepMerge<T, U, Options>