Documentation
@tsly/obj
quickDeepClone

quickDeepClone

Deeply clones the wrapped object via the JSON serialize/deserialize method.

⚠️

This method will not work for objects that have values of Date, undefined, or Infinity

import { obj } from "@tsly/obj";
 
const gizmo = { name: "gizmo", extraInfo: { tags: ["tag1", "tag2"] } };
 
// with quickDeepClone
const deepClone = obj(gizmo).quickDeepClone().take();
shallowClone == gizmo; // false
shallowClone.extraInfo.tags == gizmo.extraInfo.tags; // false
 
// with shallow clone
const shallowClone = { ...gizmo };
shallowClone == gizmo; // false
shallowClone.extraInfo.tags == gizmo.extraInfo.tags; // true

Edit on CodeSandbox (opens in a new tab)