1234567891011121314151617181920 |
- import { isDef, isObject } from "./basic.mjs";
- function deepClone(obj) {
- if (!isDef(obj)) {
- return obj;
- }
- if (Array.isArray(obj)) {
- return obj.map((item) => deepClone(item));
- }
- if (isObject(obj)) {
- const to = {};
- Object.keys(obj).forEach((key) => {
- to[key] = deepClone(obj[key]);
- });
- return to;
- }
- return obj;
- }
- export {
- deepClone
- };
|