clone.js 505 B

123456789101112131415
  1. export function clone(obj) {
  2. if (obj === null || typeof (obj) !== 'object' || 'isActiveClone' in obj) {
  3. return obj;
  4. }
  5. const temp = obj instanceof Date ? new Date(obj) : (obj.constructor());
  6. for (const key of Object.keys(obj)) {
  7. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  8. obj['isActiveClone'] = null;
  9. temp[key] = clone(obj[key]);
  10. delete obj['isActiveClone'];
  11. }
  12. }
  13. return temp;
  14. }
  15. //# sourceMappingURL=clone.js.map