UNPKG

@cnamts/vue-dot

Version:

Implementation of our Design System for the French Health Insurance

21 lines (16 loc) 435 B
/* eslint-disable @typescript-eslint/no-explicit-any */ type UnknownValue = any; /** Deep copy an object or an array without reference */ export function deepCopy<T = any>(o: UnknownValue): T { let copy = o; let k; if (o && typeof o === 'object') { copy = Object.prototype.toString.call(o) === '[object Array]' ? [] : {}; for (k in o) { if (o[k] !== undefined) { copy[k] = deepCopy(o[k]); } } } return copy; }