vant/packages/utils/deep-clone.ts
2019-02-19 16:04:29 +08:00

12 lines
256 B
TypeScript

import { deepAssign } from './deep-assign';
export function deepClone(obj: object): object {
if (Array.isArray(obj)) {
return obj.map(item => deepClone(item));
}
if (typeof obj === 'object') {
return deepAssign({}, obj);
}
return obj;
}