0.0.5 • Published 3 years ago

@xaro/deepmerge v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@xaro/deepmerge

Install

npm install @xaro/deepmerge --save-dev

Usage

import deepmerge from "@xaro/deepmerge";

const objA = {
  a: 'apple',
  b: {
    ba: 'banana',
    bb: 'broccoli'
  },
  c: [ 1, 2 ]
}

const objB = {
  a: 'asparagus',
  b: {
    bb: 'beets',
    bc: 'carrot'
  },
  c: [ 3, 4 ],
  d: 'cherry'
}

deepmerge(objA, objB);

// Result:
objA = {
  a: 'asparagus',
  b: {
    ba: 'banana',
    bb: 'beets',
    bc: 'carrot'
  },
  c: [ 3, 4 ],        << If you need to merge arrays see below
  d: 'cherry'
}


// Or if you need to merge arrays in properties, set mergeArray property to true (only boolean value) in third argument object:
deepmerge(objA, objB, { mergeArray: true });

// Result:
objA = {
  a: 'asparagus',
  b: {
    ba: 'banana',
    bb: 'beets',
    bc: 'carrot'
  },
  c: [ 1, 2, 3, 4 ],  << Here
  d: 'cherry'
}
0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago