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

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

The Fathym Reference Architecture provides the common foundation for applications built in Typescript.
Latest
function mergeWithArrays
import { mergeWithArrays } from "https://deno.land/x/fathym_common@v0.2.167/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 merged the new array.

Examples

From direct import

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

const merged = mergeWithArrays({ 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: [1, 2, 3, 4, 5, 6] }

From common import

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

const merged = mergeWithArrays({ 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: [1, 2, 3, 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.