Go to Latest
function deepMerge
import { deepMerge } from "https://deno.land/std@0.139.0/collections/deep_merge.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.


import { deepMerge } from "https://deno.land/std@0.139.0/collections/mod.ts";
import { assertEquals } from "https://deno.land/std@0.139.0/testing/asserts.ts";

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

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

Type Parameters

T extends Record<PropertyKey, unknown>


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

Type Parameters

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


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