Create a deep copy of an object instance by serializing it and reviving it
through defaultFromJSON.
Reviving (rather than handing the raw serialized JSON to the constructor) is
what makes the copy faithful: nested registered instances, Set/Map
fields, and modifier ValueDeltas come back as live objects instead of inert
plain data. Registered classes (see registerKind) are reconstructed
to their concrete type by defaultFromJSON; an unregistered top-level type
still has its children revived and is rebuilt via its own constructor.
The owning logic (parent) defaults to the source's own parent, so
modifier.clone() reuses the same owner. data overrides are merged before
reviving.
Type Parameters
T
The expected cloned type.
Parameters
instance: object
The instance to deep-copy.
data: PlainObject = {}
Field overrides merged into the serialized data before reviving.
options: PlainObject = {}
Reconstruction options; options.parent overrides the owning logic.
Create a deep copy of an object instance by serializing it and reviving it through defaultFromJSON.
Reviving (rather than handing the raw serialized JSON to the constructor) is what makes the copy faithful: nested registered instances,
Set/Mapfields, and modifierValueDeltas come back as live objects instead of inert plain data. Registered classes (see registerKind) are reconstructed to their concrete type bydefaultFromJSON; an unregistered top-level type still has its children revived and is rebuilt via its own constructor.The owning logic (
parent) defaults to the source's own parent, somodifier.clone()reuses the same owner.dataoverrides are merged before reviving.