clone.ts 271 B

123456789101112
  1. export function deepClone<T>(obj: T) {
  2. return JSON.parse(JSON.stringify(obj));
  3. }
  4. export function ensure<T extends object>(
  5. obj: T,
  6. keys: Array<[keyof T][number]>,
  7. ) {
  8. return keys.every(
  9. (k) => obj[k] !== undefined && obj[k] !== null && obj[k] !== "",
  10. );
  11. }