Deep Copy
Functions
Section titled “Functions”deepCopy()
Section titled “deepCopy()”Call Signature
Section titled “Call Signature”deepCopy<
T>(value,serializationType?,traversalDescription?,classConstructors?,insideMap?):T
Defined in: packages/isaacscript-common/src/functions/deepCopy.ts:68
deepCopy is a semi-generic deep cloner. It will recursively copy all of the values so that none
of the nested references remain.
deepCopy is used by the IsaacScript save data manager to make a backup of your variables, so
that it can restore them to the default values at the beginning of a new room, floor, or run.
deepCopy supports the following object types:
- Primitives (i.e. strings, numbers, and booleans)
- Basic TSTL objects (which are the same thing as Lua tables)
- TSTL
Map - TSTL
Set - TSTL classes
DefaultMap- Isaac
BitSet128objects - Isaac
Colorobjects - Isaac
KColorobjects - Isaac
RNGobjects - Isaac
Vectorobjects
It does not support:
- objects with values of
null(since that transpiles tonil) - other Isaac API objects such as
EntityPtr(that have a type of “userdata”)
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”T
The primitive or object to copy.
serializationType?
Section titled “serializationType?”Optional. Has 3 possible values. Can copy objects as-is, or can
serialize objects to Lua tables, or can deserialize Lua tables to
objects. Default is SerializationType.NONE.
traversalDescription?
Section titled “traversalDescription?”string
Optional. Used to track the current key that we are operating on for debugging purposes. Default is an empty string.
classConstructors?
Section titled “classConstructors?”LuaMap<string, AnyClass>
Optional. A Lua table that maps the name of a user-defined TSTL class to
its corresponding constructor. If the deepCopy function finds any
user-defined TSTL classes when recursively iterating through the given
object, it will use this map to instantiate a new class. Default is an
empty Lua table.
insideMap?
Section titled “insideMap?”boolean
Optional. Tracks whether the deep copy function is in the process of recursively copying a TSTL Map. Default is false.
Returns
Section titled “Returns”T
Call Signature
Section titled “Call Signature”deepCopy(
value,serializationType,traversalDescription?,classConstructors?,insideMap?):unknown
Defined in: packages/isaacscript-common/src/functions/deepCopy.ts:76
deepCopy is a semi-generic deep cloner. It will recursively copy all of the values so that none
of the nested references remain.
deepCopy is used by the IsaacScript save data manager to make a backup of your variables, so
that it can restore them to the default values at the beginning of a new room, floor, or run.
deepCopy supports the following object types:
- Primitives (i.e. strings, numbers, and booleans)
- Basic TSTL objects (which are the same thing as Lua tables)
- TSTL
Map - TSTL
Set - TSTL classes
DefaultMap- Isaac
BitSet128objects - Isaac
Colorobjects - Isaac
KColorobjects - Isaac
RNGobjects - Isaac
Vectorobjects
It does not support:
- objects with values of
null(since that transpiles tonil) - other Isaac API objects such as
EntityPtr(that have a type of “userdata”)
Parameters
Section titled “Parameters”unknown
The primitive or object to copy.
serializationType
Section titled “serializationType”Optional. Has 3 possible values. Can copy objects as-is, or can
serialize objects to Lua tables, or can deserialize Lua tables to
objects. Default is SerializationType.NONE.
traversalDescription?
Section titled “traversalDescription?”string
Optional. Used to track the current key that we are operating on for debugging purposes. Default is an empty string.
classConstructors?
Section titled “classConstructors?”LuaMap<string, AnyClass>
Optional. A Lua table that maps the name of a user-defined TSTL class to
its corresponding constructor. If the deepCopy function finds any
user-defined TSTL classes when recursively iterating through the given
object, it will use this map to instantiate a new class. Default is an
empty Lua table.
insideMap?
Section titled “insideMap?”boolean
Optional. Tracks whether the deep copy function is in the process of recursively copying a TSTL Map. Default is false.
Returns
Section titled “Returns”unknown
