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

x/fathym_common/src/common/merge/merge.ts>merge

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

Merges objects recursively, in a deep merge pattern. Any arrays, maps or sets that exist in both objects will be replaced with the new array.

Examples

From direct import

import { merge } from '@fathym/common/merge';

const merged = merge({ a: 1 }, { b: 2, c: 3 }, { c: 4, d: [1, 2, 3]}, { d: [4, 5, 6] });

console.log(merged); // { a: 1, b: 2, c: 4, d: [4, 5, 6] }

From common import

import { merge } from '@fathym/common';

const merged = merge({ a: 1 }, { b: 2, c: 3 }, { c: 4, d: [1, 2, 3]}, { d: [4, 5, 6] });

console.log(merged); // { a: 1, b: 2, c: 4, d: [4, 5, 6] }

Parameters

...inputs: object[]

The objects to merge. If there are multiple objects, they will be merged in the order they appear in the array.

Returns

The merged objects.