refactoring deepClone
This commit is contained in:
		| @@ -249,19 +249,6 @@ export function debounce(func, wait, immediate) { | ||||
| } | ||||
|  | ||||
| export function deepClone(source) { | ||||
|   if (!source && typeof source !== 'object') { | ||||
|     throw new Error('error arguments', 'shallowClone') | ||||
|   } | ||||
|   const targetObj = source.constructor === Array ? [] : {} | ||||
|   for (const keys in source) { | ||||
|     if (source.hasOwnProperty(keys)) { | ||||
|       if (source[keys] && typeof source[keys] === 'object') { | ||||
|         targetObj[keys] = source[keys].constructor === Array ? [] : {} | ||||
|         targetObj[keys] = deepClone(source[keys]) | ||||
|       } else { | ||||
|         targetObj[keys] = source[keys] | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   let targetObj = JSON.parse(JSON.stringify(source)); | ||||
|   return targetObj | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user