UNPKG

syncbasestore

Version:

Lightweight reactive store with built-in filtering and async state handling

18 lines (17 loc) 511 B
export function deepMerge(target, source) { const output = { ...target }; for (const key in source) { const sourceVal = source[key]; const targetVal = target[key]; if (typeof targetVal === 'object' && typeof sourceVal === 'object' && !Array.isArray(sourceVal) && sourceVal !== null) { output[key] = deepMerge(targetVal, sourceVal); } else { output[key] = sourceVal; } } return output; }