UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

44 lines 2.53 kB
import { SerializationType } from "../enums/SerializationType"; import type { AnyClass } from "../types/AnyClass"; /** * `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 `BitSet128` objects * - Isaac `Color` objects * - Isaac `KColor` objects * - Isaac `RNG` objects * - Isaac `Vector` objects * * It does not support: * - objects with values of `null` (since that transpiles to `nil`) * - other Isaac API objects such as `EntityPtr` (that have a type of "userdata") * * @param value The primitive or object to copy. * @param 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`. * @param traversalDescription Optional. Used to track the current key that we are operating on for * debugging purposes. Default is an empty string. * @param classConstructors 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. * @param insideMap Optional. Tracks whether the deep copy function is in the process of recursively * copying a TSTL Map. Default is false. */ export declare function deepCopy<T>(value: T, serializationType?: SerializationType.NONE, traversalDescription?: string, classConstructors?: LuaMap<string, AnyClass>, insideMap?: boolean): T; export declare function deepCopy(value: unknown, serializationType: SerializationType, traversalDescription?: string, classConstructors?: LuaMap<string, AnyClass>, insideMap?: boolean): unknown; //# sourceMappingURL=deepCopy.d.ts.map