UNPKG

@thangk/easythemer

Version:

Easily generate shades from a colour palette for use in your app

25 lines (19 loc) 881 B
import { ValidateIsObject } from "../validators"; export default function mergeObjects<T>(object1: any, object2: any) { if (!object2) return; const workingObject = structuredClone(object1); console.log("workingObject", workingObject); for (const [key, value] of Object.entries(workingObject)) { const isValueAnObject = new ValidateIsObject(value); const valueKeysLen = Object.keys(workingObject[key]).length; console.log(`${key}: ${value}`); console.log("isValueAnObject", isValueAnObject); console.log("valueKeysLen", valueKeysLen); if (valueKeysLen && isValueAnObject.getResult) { workingObject[key] = mergeObjects(workingObject[key], object2[key]); continue; } workingObject[key] = object2[key] ?? workingObject[key]; } return workingObject as T; }