添加工具
This commit is contained in:
parent
555658ce1e
commit
3cb86f446b
@ -146,4 +146,21 @@ export function deepClone(obj: any) {
|
|||||||
result[key] = deepClone(value);
|
result[key] = deepClone(value);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 深度复制
|
||||||
|
* @param obj 待复制的对象
|
||||||
|
* @param result 要复制到的对象
|
||||||
|
* @returns 复制的对象
|
||||||
|
*/
|
||||||
|
export function deepCloneTo<T>(obj: T,result:T) {
|
||||||
|
if (obj == null || typeof obj !== 'object') {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
for (let [key, value] of Object.entries(obj)) {
|
||||||
|
// @ts-ignore
|
||||||
|
result[key] = deepClone(value);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user