lib/util.js
function getPatchedObject (obj, patcher, clone = true) {
  if (!patcher) {
    return obj
  }
  let newObj, newPatcher
  if (clone) {
    newObj = getDeepCopiedObject(obj)
    newPatcher = getDeepCopiedObject(patcher)
  } else {
    newObj = obj
    newPatcher = patcher
  }
  // patch
  const keys = Object.keys(newPatcher)
  for (let i = 0; i < keys.length; i++) {
    const key = keys[i]
    if ((key in newObj) && isRealObject(newObj[key]) && isRealObject(newPatcher[key])) {
      // recursive patch for if value type is newObject
      try {
        newObj[key] = getPatchedObject(newObj[key], newPatcher[key], false)
      } catch (error) {
      // do nothing, just skip
      }
    } else {
      // simple replacement if value type is not newObject
      newObj[key] = newPatcher[key]
    }
  }
  return newObj
}
function getPatchedObject (obj, patcher, clone = true) {
  if (!patcher) {
    return obj
  }
  let newObj, newPatcher
  if (clone) {
    newObj = getDeepCopiedObject(obj)
    newPatcher = getDeepCopiedObject(patcher)
  } else {
    newObj = obj
    newPatcher = patcher
  }
  // patch
  const keys = Object.keys(newPatcher)
  for (let i = 0; i < keys.length; i++) {
    const key = keys[i]
    if ((key in newObj) && isRealObject(newObj[key]) && isRealObject(newPatcher[key])) {
      // recursive patch for if value type is newObject
      try {
        newObj[key] = getPatchedObject(newObj[key], newPatcher[key], false)
      } catch (error) {
      // do nothing, just skip
      }
    } else {
      // simple replacement if value type is not newObject
      newObj[key] = newPatcher[key]
    }
  }
  return newObj
}
function getPatchedObject ( obj , patcher , clone = true ) { if ( ! patcher ) { return obj } let newObj , newPatcher if ( clone ) { newObj = getDeepCopiedObject ( obj ) newPatcher = getDeepCopiedObject ( patcher ) } else { newObj = obj newPatcher = patcher } // patch const keys = Object . keys ( newPatcher ) for ( let i = 0 ; i < keys . length ; i ++ ) { const key = keys [ i ] if ( ( key in newObj ) && isRealObject ( newObj [ key ] ) && isRealObject ( newPatcher [ key ] ) ) { // recursive patch for if value type is newObject try { newObj [ key ] = getPatchedObject ( newObj [ key ] , newPatcher [ key ] , false ) } catch ( error ) { // do nothing, just skip } } else { // simple replacement if value type is not newObject newObj [ key ] = newPatcher [ key ] } } return newObj }
patch object with patcher
patch object with patcher