export function deepClone(source: T) { if (typeof source !== 'object' || source === null) { return source } let result = (Array.isArray(source) ? [] : {}) as T for (let key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { result[key] = (typeof source[key] === 'object') ? deepClone(source[key]) : source[key] } } return result }