function mergeImmutable (source, addition) {
  // filtering out unmeargeable data
  if (
    typeof source !== 'object' ||
    source === null ||
    Array.isArray(source) || // merging arrays makes no sense
    typeof addition !== 'object' ||
    addition === null ||
    Array.isArray(addition)
  ) {
    return addition
  }

  const clone = Object.assign({}, source)

  Object.keys(addition).forEach((key) => {
    clone[key] = mergeImmutable(clone[key], addition[key])
  })

  return clone
}
/**
 * Deeply merges an object on top of another with the minimum amount of cloning
 * @param source
 * @param addition
 *
 * @example
 * const source = { a: { b: 1, c: 2 }, z: {...} };
 * const addition = { a: { b: 3 }, e: 5 };
 * mergeImmutable(source, addition)
 * // { a: { b: 3, c: 2 }, e: 5, z: {...} }
 * // z is not mentioned in the addition and thus it has not been deep cloned
 */
Deeply merges an object on top of another with the minimum amount of cloning
@param source
@param addition


Deeply merges an object on top of another with the minimum amount of cloning @param source @param addition
function mergeImmutable (source, addition) {
  if (
    typeof source !== 'object' ||
    source === null ||
    Array.isArray(source) || 
    typeof addition !== 'object' ||
    addition === null ||
    Array.isArray(addition)
  ) {
    return addition
  }
  const clone = Object.assign({}, source)
  Object.keys(addition).forEach((key) => {
    clone[key] = mergeImmutable(clone[key], addition[key])
  })
  return clone
}
function mergeImmutable ( source , addition ) { if ( typeof source !== 'object' || source === null || Array . isArray ( source ) || typeof addition !== 'object' || addition === null || Array . isArray ( addition ) ) { return addition } const clone = Object . assign ( { } , source ) Object . keys ( addition ) . forEach ( ( key ) => { clone [ key ] = mergeImmutable ( clone [ key ] , addition [ key ] ) } ) return clone }
Deeply merges an object on top of another with the minimum amount of cloning
 @param source
 @param addition
Deeply merges an object on top of another with the minimum amount of cloning @param source @param addition
// filtering out unmeargeable data // merging arrays makes no sense