mergeDeep

Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.object

Deep merge one object with another and return the merged object result. This merging implementation support:

  • Merging object with getters/setters
  • n numbers of objects as arguments
  • Choose beetween cloning first (default) the object or keeping the first passed object as result Note that by default the resulting object is a clone and do not have the same reference that the first passed object.

Params

  1. objects*-any[]

    Pass all the objects you want to merge

  2. settings{}TMergeDeepSettings

    Some settings to configure your merging process

Return

  1. -Object

    The merged object result

Example

import { mergeDeep } from '@blackbyte/sugar/object';
mergeDeep([{a: {b: {c: 'c', d: 'd'}}}, {a: {b: {e: 'e', f: 'f'}}}]);
// => { a: { b: { c: 'c', d: 'd', e: 'e', f: 'f' } } }

Settings

  1. arrayfalseBoolean

    Merge or not arrays

  2. clonetrueBoolean

    Specify if you want the result object to be a clone or the same first passed object

Todo

  • testsnormal