Skip to content

jesusgm/deepmergefn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deepMerge

npm Build Status Number of Downloads

Mixes two data objects in depth

Installation

Install package executing these command:

    npm i deepmergefn

Usage

const deepMerge = require("deepmergefn");

const object1 = {
  name: "John",
  lastname: "Doe",
  list: [
    {
      foo: 2,
    },
    {
      var: "aaa",
    },
  ],
};

const object2 = {
  name: "John",
  age: 30,
  list: [
    {
      foobar: "lastaaa",
    },
  ],
};

const result = deepMerge(object1, object2);

Returns

{
  "name": "John",
  "lastname": "Doe",
  "list": [
    {
      "foo": 2,
      "foobar": "lastaaa"
    },
    {
      "var": "aaa"
    }
  ],
  "age": 30
}

Demo

You can test this package here

License

MIT