Ctrl K
ComunidadGuías…

utils/object.ts

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
function deepMerge(target: { [key: string]: any }, source: { [key: string]: any }) {
  for (let key in source) {
    if (source.hasOwnProperty(key)) {
      if (typeof source[key] === 'object' && source[key] !== null) {
        if (!target[key] || typeof target[key] !== 'object') {
          target[key] = Array.isArray(source[key]) ? [] : {};
        }
        deepMerge(target[key], source[key]);
      } else {
        target[key] = source[key];
      }
    }
  }
  return target;
}

export {
  deepMerge,
}