ChatGPT-Next-Web/app/utils/clone.ts

11 lines
245 B
TypeScript
Raw Normal View History

export function deepClone<T>(obj: T) {
return JSON.parse(JSON.stringify(obj));
}
2023-11-09 18:43:30 +00:00
export function ensure<T extends object>(
obj: T,
keys: Array<[keyof T][number]>,
) {
return keys.every((k) => obj[k] !== undefined && obj[k] !== null);
}