基于vue3.0和element-plus的组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
643 B

import { cloneDeep } from "lodash-es";
export function deepCopy<T = any>(obj: T): T {
return cloneDeep(obj);
}
export function clearObject(obj: Record<string, any>) {
for (const key in obj) {
delete obj[key];
}
}
export function clearAndAssign(target: Record<string, any>, source: Record<string, any>) {
clearObject(target);
Object.assign(target, source);
}
export function unnest(obj: Record<string, any>, key: string, prefix: string) {
const { [key]: toFlatten, ...rest } = obj;
const prefixed = Object.fromEntries(Object.entries(toFlatten).map(([k, v]) => [prefix.concat(k), v]));
return { ...rest, ...prefixed };
}