The minimalistic document archiving platform.
export function isObject(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value);
}
export function deepMerge<T extends Record<string, unknown>>(
target: T,
source: Record<string, unknown>,
): T {
const result: Record<string, unknown> = { ...target };
for (const key in source) {
if (source[key] === undefined) {
continue;
}
if (isObject(source[key]) && isObject(result[key])) {
result[key] = deepMerge(
result[key] as Record<string, unknown>,
source[key] as Record<string, unknown>,
);
} else {
result[key] = source[key];
}
}
return result as T;
}