isaacscript-common 3.15.0 → 3.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/callbacks/postPlayerFatalDamage.lua +27 -1
  2. package/classes/DefaultMap.lua +6 -4
  3. package/enums/ModCallbackCustom.d.ts +1 -1
  4. package/features/deployJSONRoom.lua +62 -17
  5. package/features/saveDataManager/exports.lua +7 -6
  6. package/features/saveDataManager/load.lua +7 -5
  7. package/features/saveDataManager/main.lua +2 -2
  8. package/features/saveDataManager/merge.lua +12 -16
  9. package/features/saveDataManager/save.lua +2 -2
  10. package/features/saveDataManager/serializationBrand.lua +3 -1
  11. package/functions/ambush.lua +1 -1
  12. package/functions/array.d.ts +1 -0
  13. package/functions/array.lua +18 -12
  14. package/functions/color.lua +6 -7
  15. package/functions/deepCopy.lua +27 -24
  16. package/functions/deepCopyTests.lua +23 -27
  17. package/functions/entity.d.ts +4 -1
  18. package/functions/entity.lua +22 -25
  19. package/functions/enums.lua +3 -1
  20. package/functions/gridEntity.d.ts +3 -3
  21. package/functions/gridEntity.lua +7 -7
  22. package/functions/isaacAPIClass.lua +5 -3
  23. package/functions/jsonHelpers.d.ts +1 -1
  24. package/functions/jsonHelpers.lua +4 -4
  25. package/functions/kColor.lua +6 -7
  26. package/functions/log.d.ts +9 -2
  27. package/functions/log.lua +30 -21
  28. package/functions/rng.lua +10 -12
  29. package/functions/serialization.d.ts +1 -1
  30. package/functions/serialization.lua +9 -7
  31. package/functions/table.d.ts +14 -10
  32. package/functions/table.lua +54 -37
  33. package/functions/tstlClass.lua +6 -4
  34. package/functions/types.d.ts +10 -0
  35. package/functions/types.lua +25 -0
  36. package/functions/utils.d.ts +0 -2
  37. package/functions/utils.lua +0 -6
  38. package/functions/vector.lua +6 -7
  39. package/index.d.ts +1 -0
  40. package/index.lua +8 -0
  41. package/package.json +1 -1
package/functions/rng.lua CHANGED
@@ -1,4 +1,5 @@
1
1
  local ____lualib = require("lualib_bundle")
2
+ local __TS__TypeOf = ____lualib.__TS__TypeOf
2
3
  local __TS__ObjectValues = ____lualib.__TS__ObjectValues
3
4
  local ____exports = {}
4
5
  local RECOMMENDED_SHIFT_IDX, OBJECT_NAME
@@ -14,6 +15,8 @@ local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
14
15
  local ____table = require("functions.table")
15
16
  local getNumbersFromTable = ____table.getNumbersFromTable
16
17
  local tableHasKeys = ____table.tableHasKeys
18
+ local ____types = require("functions.types")
19
+ local isTable = ____types.isTable
17
20
  local ____utils = require("functions.utils")
18
21
  local ensureAllCases = ____utils.ensureAllCases
19
22
  --- Helper function to get a random `Seed` value to be used in spawning entities and so on. Use this
@@ -86,8 +89,7 @@ function ____exports.copyRNG(self, rng, serializationType)
86
89
  ____cond3 = ____cond3 or ____switch3 == SerializationType.DESERIALIZE
87
90
  if ____cond3 then
88
91
  do
89
- local rngType = type(rng)
90
- if ____exports.isRNG(nil, rng) or rngType ~= "table" then
92
+ if not isTable(nil, rng) then
91
93
  error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
92
94
  end
93
95
  local seedNumber = table.unpack(getNumbersFromTable(
@@ -110,16 +112,14 @@ end
110
112
  --- Used to determine is the given table is a serialized `RNG` object created by the save data
111
113
  -- manager and/or the `deepCopy` function.
112
114
  function ____exports.isSerializedRNG(self, object)
113
- local objectType = type(object)
114
- if objectType ~= "table" then
115
+ if not isTable(nil, object) then
115
116
  return false
116
117
  end
117
- local ____table = object
118
118
  return tableHasKeys(
119
119
  nil,
120
- ____table,
120
+ object,
121
121
  table.unpack(KEYS)
122
- ) and ____table[SerializationBrand.RNG] ~= nil
122
+ ) and object[SerializationBrand.RNG] ~= nil
123
123
  end
124
124
  function ____exports.rngEquals(self, rng1, rng2)
125
125
  return isaacAPIClassEquals(nil, rng1, rng2, KEYS)
@@ -127,12 +127,10 @@ end
127
127
  --- Helper function to iterate over the provided object and set the seed for all of the values that
128
128
  -- are RNG objects equal to a particular seed.
129
129
  function ____exports.setAllRNGToSeed(self, object, seed)
130
- local objectType = type(object)
131
- if objectType ~= "table" then
132
- error("Failed to iterate over the object containing RNG objects since the type of the provided object was: " .. objectType)
130
+ if not isTable(nil, object) then
131
+ error("Failed to iterate over the object containing RNG objects since the type of the provided object was: " .. __TS__TypeOf(object))
133
132
  end
134
- local ____table = object
135
- for ____, value in ipairs(__TS__ObjectValues(____table)) do
133
+ for ____, value in ipairs(__TS__ObjectValues(table)) do
136
134
  if ____exports.isRNG(nil, value) then
137
135
  ____exports.setSeed(nil, value, seed)
138
136
  end
@@ -5,7 +5,7 @@ export declare function copyIsaacAPIClass(isaacAPIClass: unknown, serializationT
5
5
  * Deserialization is a special case, so we make a dedicated function for this.
6
6
  *
7
7
  * There is no need for a corresponding "serializeIsaacAPIClass" function because the
8
- * "copyIsaacAPIClass" function can handles all serialization types.
8
+ * "copyIsaacAPIClass" function can handle all serialization types.
9
9
  */
10
10
  export declare function deserializeIsaacAPIClass(serializedIsaacAPIClass: SerializedIsaacAPIClass): unknown;
11
11
  export declare function isSerializedIsaacAPIClass(object: unknown): object is SerializedIsaacAPIClass;
@@ -1,4 +1,5 @@
1
1
  local ____lualib = require("lualib_bundle")
2
+ local __TS__TypeOf = ____lualib.__TS__TypeOf
2
3
  local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
3
4
  local __TS__ObjectValues = ____lualib.__TS__ObjectValues
4
5
  local __TS__ArraySome = ____lualib.__TS__ArraySome
@@ -14,6 +15,9 @@ local ____serializedIsaacAPIClassTypeToIdentityFunction = require("objects.seria
14
15
  local SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = ____serializedIsaacAPIClassTypeToIdentityFunction.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION
15
16
  local ____isaacAPIClass = require("functions.isaacAPIClass")
16
17
  local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
18
+ local ____types = require("functions.types")
19
+ local isTable = ____types.isTable
20
+ local isUserdata = ____types.isUserdata
17
21
  function getSerializedTableType(self, serializedIsaacAPIClass)
18
22
  for ____, ____value in ipairs(__TS__ObjectEntries(ISAAC_API_CLASS_TYPE_TO_BRAND)) do
19
23
  local copyableIsaacAPIClassType = ____value[1]
@@ -25,9 +29,8 @@ function getSerializedTableType(self, serializedIsaacAPIClass)
25
29
  return nil
26
30
  end
27
31
  function ____exports.copyIsaacAPIClass(self, isaacAPIClass, serializationType)
28
- local objectType = type(isaacAPIClass)
29
- if objectType ~= "userdata" then
30
- error("Failed to copy an Isaac API class since the provided object was of type: " .. objectType)
32
+ if not isUserdata(nil, isaacAPIClass) then
33
+ error("Failed to copy an Isaac API class since the provided object was of type: " .. __TS__TypeOf(isaacAPIClass))
31
34
  end
32
35
  local isaacAPIClassType = getIsaacAPIClassName(nil, isaacAPIClass)
33
36
  if isaacAPIClassType == nil then
@@ -43,11 +46,10 @@ end
43
46
  --- Deserialization is a special case, so we make a dedicated function for this.
44
47
  --
45
48
  -- There is no need for a corresponding "serializeIsaacAPIClass" function because the
46
- -- "copyIsaacAPIClass" function can handles all serialization types.
49
+ -- "copyIsaacAPIClass" function can handle all serialization types.
47
50
  function ____exports.deserializeIsaacAPIClass(self, serializedIsaacAPIClass)
48
- local objectType = type(serializedIsaacAPIClass)
49
- if objectType ~= "table" then
50
- error("Failed to deserialize an Isaac API class since the provided object was of type: " .. objectType)
51
+ if not isTable(nil, serializedIsaacAPIClass) then
52
+ error("Failed to deserialize an Isaac API class since the provided object was of type: " .. __TS__TypeOf(serializedIsaacAPIClass))
51
53
  end
52
54
  local copyableIsaacAPIClassType = getSerializedTableType(nil, serializedIsaacAPIClass)
53
55
  if copyableIsaacAPIClassType == nil then
@@ -3,46 +3,50 @@
3
3
  * In a Map, you can use the `clear` method to delete every element. However, in a LuaTable, the
4
4
  * `clear` method does not exist. Use this helper function as a drop-in replacement for this.
5
5
  */
6
- export declare function clearTable(table: LuaTable): void;
6
+ export declare function clearTable(luaTable: LuaTable): void;
7
7
  /** Helper function to copy specific values from a object to a table. */
8
- export declare function copyValuesToTable(object: unknown, keys: string[], table: LuaTable<string, unknown>): void;
8
+ export declare function copyValuesToTable(object: unknown, keys: string[], luaTable: LuaTable<string, unknown>): void;
9
9
  /**
10
10
  * Helper function to safely get boolean values from a Lua table. Will throw an error if the
11
11
  * specific value does not exist on the table.
12
12
  *
13
13
  * This function is variadic, meaning that you can specify N arguments to get N values.
14
14
  */
15
- export declare function getBooleansFromTable(table: LuaTable<string, unknown>, objectName: string, ...keys: string[]): boolean[];
15
+ export declare function getBooleansFromTable(luaTable: LuaTable<string, unknown>, objectName: string, ...keys: string[]): boolean[];
16
16
  /**
17
17
  * Helper function to safely get number values from a Lua table. Will throw an error if the specific
18
18
  * value does not exist on the table or if it cannot be converted to a number.
19
19
  *
20
20
  * This function is variadic, meaning that you can specify N arguments to get N values.
21
21
  */
22
- export declare function getNumbersFromTable(table: LuaTable<string, unknown>, objectName: string, ...keys: string[]): number[];
22
+ export declare function getNumbersFromTable(luaTable: LuaTable<string, unknown>, objectName: string, ...keys: string[]): number[];
23
23
  /**
24
24
  * Helper function to safely get string values from a Lua table. Will throw an error if the specific
25
25
  * value does not exist on the table.
26
26
  *
27
27
  * This function is variadic, meaning that you can specify N arguments to get N values.
28
28
  */
29
- export declare function getStringsFromTable(table: LuaTable<string, unknown>, objectName: string, ...keys: string[]): string[];
29
+ export declare function getStringsFromTable(luaTable: LuaTable<string, unknown>, objectName: string, ...keys: string[]): string[];
30
30
  /**
31
31
  * Helper function to iterate over a table deterministically. This is useful because by default, the
32
32
  * `pairs` function will return the keys of a Lua table in a random order.
33
33
  *
34
34
  * This function will sort the table entries based on the value of the key.
35
35
  *
36
- * @param table The table to iterate over.
36
+ * This function will only work on tables that have number keys or string keys. It will throw a
37
+ * runtime error if it encounters a key of another type.
38
+ *
39
+ * @param luaTable The table to iterate over.
37
40
  * @param func The function to run for each iteration.
38
- * @param deterministic Optional. Whether to iterate deterministically. True by default. You can
39
- * dynamically set to false in situations where you need extra performance.
41
+ * @param inOrder Optional. Whether to iterate in order. True by default. You can dynamically set to
42
+ * false in situations where iterating randomly would not matter and you need the
43
+ * extra performance.
40
44
  */
41
- export declare function iterateTableDeterministically<K, V>(table: LuaTable<K, V>, func: (key: K, value: V) => void, deterministic?: boolean): void;
45
+ export declare function iterateTableInOrder<K, V>(luaTable: LuaTable<K, V>, func: (key: K, value: V) => void, inOrder?: boolean): void;
42
46
  /**
43
47
  * Helper function to check if a Lua table has all of the provided keys.
44
48
  *
45
49
  * This function is variadic, meaning that you can specify as many arguments as you want to check
46
50
  * for.
47
51
  */
48
- export declare function tableHasKeys(table: LuaTable<AnyNotNil, unknown>, ...keys: string[]): boolean;
52
+ export declare function tableHasKeys(luaTable: LuaTable<AnyNotNil, unknown>, ...keys: string[]): boolean;
@@ -1,38 +1,41 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__TypeOf = ____lualib.__TS__TypeOf
3
- local __TS__ArraySort = ____lualib.__TS__ArraySort
3
+ local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
4
4
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
5
+ local __TS__ArraySort = ____lualib.__TS__ArraySort
5
6
  local ____exports = {}
6
- local ____utils = require("functions.utils")
7
- local twoDimensionalSort = ____utils.twoDimensionalSort
7
+ local ____types = require("functions.types")
8
+ local isBoolean = ____types.isBoolean
9
+ local isNumber = ____types.isNumber
10
+ local isString = ____types.isString
8
11
  --- In a Map, you can use the `clear` method to delete every element. However, in a LuaTable, the
9
12
  -- `clear` method does not exist. Use this helper function as a drop-in replacement for this.
10
- function ____exports.clearTable(self, ____table)
11
- for key in pairs(____table) do
12
- ____table[key] = nil
13
+ function ____exports.clearTable(self, luaTable)
14
+ for key in pairs(luaTable) do
15
+ luaTable[key] = nil
13
16
  end
14
17
  end
15
18
  --- Helper function to copy specific values from a object to a table.
16
- function ____exports.copyValuesToTable(self, object, keys, ____table)
19
+ function ____exports.copyValuesToTable(self, object, keys, luaTable)
17
20
  local otherTable = object
18
21
  for ____, key in ipairs(keys) do
19
22
  local value = otherTable[key]
20
- ____table[key] = value
23
+ luaTable[key] = value
21
24
  end
22
25
  end
23
26
  --- Helper function to safely get boolean values from a Lua table. Will throw an error if the
24
27
  -- specific value does not exist on the table.
25
28
  --
26
29
  -- This function is variadic, meaning that you can specify N arguments to get N values.
27
- function ____exports.getBooleansFromTable(self, ____table, objectName, ...)
30
+ function ____exports.getBooleansFromTable(self, luaTable, objectName, ...)
28
31
  local keys = {...}
29
32
  local booleans = {}
30
33
  for ____, key in ipairs(keys) do
31
- local value = ____table[key]
34
+ local value = luaTable[key]
32
35
  if value == nil then
33
36
  error(((("Failed to find a value for \"" .. key) .. "\" in a table representing a \"") .. objectName) .. "\" object.")
34
37
  end
35
- if type(value) == "boolean" then
38
+ if isBoolean(nil, value) then
36
39
  booleans[#booleans + 1] = value
37
40
  else
38
41
  error((((("Failed to get the boolean for the \"" .. key) .. "\" value of a table representing a \"") .. objectName) .. "\" object because the type was: ") .. __TS__TypeOf(value))
@@ -44,17 +47,17 @@ end
44
47
  -- value does not exist on the table or if it cannot be converted to a number.
45
48
  --
46
49
  -- This function is variadic, meaning that you can specify N arguments to get N values.
47
- function ____exports.getNumbersFromTable(self, ____table, objectName, ...)
50
+ function ____exports.getNumbersFromTable(self, luaTable, objectName, ...)
48
51
  local keys = {...}
49
52
  local numbers = {}
50
53
  for ____, key in ipairs(keys) do
51
- local value = ____table[key]
54
+ local value = luaTable[key]
52
55
  if value == nil then
53
56
  error(((("Failed to find a value for \"" .. key) .. "\" in a table representing a \"") .. objectName) .. "\" object.")
54
57
  end
55
- if type(value) == "number" then
58
+ if isNumber(nil, value) then
56
59
  numbers[#numbers + 1] = value
57
- elseif type(value) == "string" then
60
+ elseif isString(nil, value) then
58
61
  local number = tonumber(value)
59
62
  if number == nil then
60
63
  error((((("Failed to convert the \"" .. key) .. "\" value of a table representing a \"") .. objectName) .. "\" object to a number: ") .. value)
@@ -70,15 +73,15 @@ end
70
73
  -- value does not exist on the table.
71
74
  --
72
75
  -- This function is variadic, meaning that you can specify N arguments to get N values.
73
- function ____exports.getStringsFromTable(self, ____table, objectName, ...)
76
+ function ____exports.getStringsFromTable(self, luaTable, objectName, ...)
74
77
  local keys = {...}
75
78
  local strings = {}
76
79
  for ____, key in ipairs(keys) do
77
- local value = ____table[key]
80
+ local value = luaTable[key]
78
81
  if value == nil then
79
82
  error(((("Failed to find a value for \"" .. key) .. "\" in a table representing a \"") .. objectName) .. "\" object.")
80
83
  end
81
- if type(value) == "string" then
84
+ if isString(nil, value) then
82
85
  strings[#strings + 1] = value
83
86
  else
84
87
  local ____string = tostring(value)
@@ -92,41 +95,55 @@ end
92
95
  --
93
96
  -- This function will sort the table entries based on the value of the key.
94
97
  --
95
- -- @param table The table to iterate over.
98
+ -- This function will only work on tables that have number keys or string keys. It will throw a
99
+ -- runtime error if it encounters a key of another type.
100
+ --
101
+ -- @param luaTable The table to iterate over.
96
102
  -- @param func The function to run for each iteration.
97
- -- @param deterministic Optional. Whether to iterate deterministically. True by default. You can
98
- -- dynamically set to false in situations where you need extra performance.
99
- function ____exports.iterateTableDeterministically(self, ____table, func, deterministic)
100
- if deterministic == nil then
101
- deterministic = true
103
+ -- @param inOrder Optional. Whether to iterate in order. True by default. You can dynamically set to
104
+ -- false in situations where iterating randomly would not matter and you need the
105
+ -- extra performance.
106
+ function ____exports.iterateTableInOrder(self, luaTable, func, inOrder)
107
+ if inOrder == nil then
108
+ inOrder = true
102
109
  end
103
- if not deterministic then
104
- for key, value in pairs(____table) do
110
+ if not inOrder then
111
+ for key, value in pairs(luaTable) do
105
112
  func(nil, key, value)
106
113
  end
107
114
  return
108
115
  end
109
- local entriesArray = {}
110
- for key, value in pairs(____table) do
111
- local entry = {key, value}
112
- entriesArray[#entriesArray + 1] = entry
116
+ local keys = __TS__ObjectKeys(luaTable)
117
+ local hasAllNumberKeys = __TS__ArrayEvery(
118
+ keys,
119
+ function(____, key) return isNumber(nil, key) end
120
+ )
121
+ local hasAllStringKeys = __TS__ArrayEvery(
122
+ keys,
123
+ function(____, key) return isString(nil, key) end
124
+ )
125
+ if not hasAllNumberKeys and not hasAllStringKeys then
126
+ for key, value in pairs(luaTable) do
127
+ func(nil, key, value)
128
+ end
129
+ return
113
130
  end
114
- __TS__ArraySort(entriesArray, twoDimensionalSort)
115
- for ____, ____value in ipairs(entriesArray) do
116
- local key = ____value[1]
117
- local value = ____value[2]
118
- func(nil, key, value)
131
+ __TS__ArraySort(keys)
132
+ for ____, key in ipairs(keys) do
133
+ local keyIndex = key
134
+ local value = luaTable[keyIndex]
135
+ func(nil, keyIndex, value)
119
136
  end
120
137
  end
121
138
  --- Helper function to check if a Lua table has all of the provided keys.
122
139
  --
123
140
  -- This function is variadic, meaning that you can specify as many arguments as you want to check
124
141
  -- for.
125
- function ____exports.tableHasKeys(self, ____table, ...)
142
+ function ____exports.tableHasKeys(self, luaTable, ...)
126
143
  local keys = {...}
127
144
  return __TS__ArrayEvery(
128
145
  keys,
129
- function(____, key) return ____table[key] ~= nil end
146
+ function(____, key) return luaTable[key] ~= nil end
130
147
  )
131
148
  end
132
149
  return ____exports
@@ -3,6 +3,9 @@ local Set = ____lualib.Set
3
3
  local __TS__New = ____lualib.__TS__New
4
4
  local ____exports = {}
5
5
  local newTSTLClassFromMetatable, VANILLA_TSTL_CLASSES
6
+ local ____types = require("functions.types")
7
+ local isString = ____types.isString
8
+ local isTable = ____types.isTable
6
9
  --- Helper function to get the name of a TypeScriptToLua class. TSTL classes are Lua tables created
7
10
  -- with the `__TS__Class` Lua function from the TSTL lualib. Their name is contained within
8
11
  -- "constructor.name" metatable key.
@@ -12,7 +15,7 @@ local newTSTLClassFromMetatable, VANILLA_TSTL_CLASSES
12
15
  -- Returns undefined if the object is not a table or if the aforementioned metatable key does not
13
16
  -- exist.
14
17
  function ____exports.getTSTLClassName(self, object)
15
- if type(object) ~= "table" then
18
+ if not isTable(nil, object) then
16
19
  return nil
17
20
  end
18
21
  local metatable = getmetatable(object)
@@ -76,8 +79,7 @@ function ____exports.isUserDefinedTSTLClass(self, object)
76
79
  if ____exports.isVanillaTSTLClass(nil, object) or ____exports.isIsaacScriptCommonClass(nil, object) then
77
80
  return false
78
81
  end
79
- local objectType = type(object)
80
- if objectType ~= "table" then
82
+ if not isTable(nil, object) then
81
83
  return false
82
84
  end
83
85
  local metatable = getmetatable(object)
@@ -87,7 +89,7 @@ function ____exports.isUserDefinedTSTLClass(self, object)
87
89
  local numKeys = 0
88
90
  for key in pairs(metatable) do
89
91
  numKeys = numKeys + 1
90
- if type(key) ~= "string" then
92
+ if not isString(nil, key) then
91
93
  return false
92
94
  end
93
95
  if not TSTL_CLASS_METATABLE_KEYS:has(key) then
@@ -0,0 +1,10 @@
1
+ /// <reference types="typescript-to-lua/language-extensions" />
2
+ /// <reference types="lua-types/5.3" />
3
+ export declare function isBoolean(variable: unknown): variable is boolean;
4
+ export declare function isFunction(variable: unknown): variable is Function;
5
+ export declare function isNumber(variable: unknown): variable is number;
6
+ /** Helper function to detect if a variable is a boolean, number, or string. */
7
+ export declare function isPrimitive(variable: unknown): variable is boolean | number | string;
8
+ export declare function isString(variable: unknown): variable is string;
9
+ export declare function isTable(variable: unknown): variable is LuaTable;
10
+ export declare function isUserdata(variable: unknown): variable is LuaUserdata;
@@ -0,0 +1,25 @@
1
+ local ____exports = {}
2
+ function ____exports.isBoolean(self, variable)
3
+ return type(variable) == "boolean"
4
+ end
5
+ function ____exports.isFunction(self, variable)
6
+ return type(variable) == "function"
7
+ end
8
+ function ____exports.isNumber(self, variable)
9
+ return type(variable) == "number"
10
+ end
11
+ --- Helper function to detect if a variable is a boolean, number, or string.
12
+ function ____exports.isPrimitive(self, variable)
13
+ local variableType = type(variable)
14
+ return variableType == "boolean" or variableType == "number" or variableType == "string"
15
+ end
16
+ function ____exports.isString(self, variable)
17
+ return type(variable) == "string"
18
+ end
19
+ function ____exports.isTable(self, variable)
20
+ return type(variable) == "table"
21
+ end
22
+ function ____exports.isUserdata(self, variable)
23
+ return type(variable) == "userdata"
24
+ end
25
+ return ____exports
@@ -66,8 +66,6 @@ export declare function hexToKColor(hexString: string, alpha: float): KColor;
66
66
  * If only one argument is specified, then it will assume that the start is 0.
67
67
  */
68
68
  export declare function irange(start: int, end?: int): int[];
69
- /** Helper function to detect if a variable is a boolean, number, or string. */
70
- export declare function isPrimitive(variable: unknown): boolean;
71
69
  /**
72
70
  * Since this is a UI element, we do not want to draw it in water reflections. `renderOffset` will
73
71
  * be a non-zero value in reflections.
@@ -1,7 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__StringReplace = ____lualib.__TS__StringReplace
3
3
  local __TS__StringSubstr = ____lualib.__TS__StringSubstr
4
- local __TS__TypeOf = ____lualib.__TS__TypeOf
5
4
  local ____exports = {}
6
5
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
6
  local RenderMode = ____isaac_2Dtypescript_2Ddefinitions.RenderMode
@@ -120,11 +119,6 @@ function ____exports.irange(self, start, ____end)
120
119
  end
121
120
  return array
122
121
  end
123
- --- Helper function to detect if a variable is a boolean, number, or string.
124
- function ____exports.isPrimitive(self, variable)
125
- local ____type = __TS__TypeOf(variable)
126
- return ____type == "boolean" or ____type == "number" or ____type == "string"
127
- end
128
122
  --- Since this is a UI element, we do not want to draw it in water reflections. `renderOffset` will
129
123
  -- be a non-zero value in reflections.
130
124
  function ____exports.isReflectionRender(self)
@@ -13,6 +13,8 @@ local ____table = require("functions.table")
13
13
  local copyValuesToTable = ____table.copyValuesToTable
14
14
  local getNumbersFromTable = ____table.getNumbersFromTable
15
15
  local tableHasKeys = ____table.tableHasKeys
16
+ local ____types = require("functions.types")
17
+ local isTable = ____types.isTable
16
18
  local ____utils = require("functions.utils")
17
19
  local ensureAllCases = ____utils.ensureAllCases
18
20
  --- Helper function to check if something is an instantiated Vector object.
@@ -56,8 +58,7 @@ function ____exports.copyVector(self, vector, serializationType)
56
58
  ____cond3 = ____cond3 or ____switch3 == SerializationType.DESERIALIZE
57
59
  if ____cond3 then
58
60
  do
59
- local vectorType = type(vector)
60
- if ____exports.isVector(nil, vector) or vectorType ~= "table" then
61
+ if not isTable(nil, vector) then
61
62
  error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
62
63
  end
63
64
  local x, y = table.unpack(getNumbersFromTable(
@@ -85,16 +86,14 @@ end
85
86
  --- Used to determine is the given table is a serialized `Vector` object created by the save data
86
87
  -- manager and/or the `deepCopy` function.
87
88
  function ____exports.isSerializedVector(self, object)
88
- local objectType = type(object)
89
- if objectType ~= "table" then
89
+ if not isTable(nil, object) then
90
90
  return false
91
91
  end
92
- local ____table = object
93
92
  return tableHasKeys(
94
93
  nil,
95
- ____table,
94
+ object,
96
95
  table.unpack(KEYS)
97
- ) and ____table[SerializationBrand.VECTOR] ~= nil
96
+ ) and object[SerializationBrand.VECTOR] ~= nil
98
97
  end
99
98
  function ____exports.vectorEquals(self, vector1, vector2)
100
99
  return isaacAPIClassEquals(nil, vector1, vector2, KEYS)
package/index.d.ts CHANGED
@@ -108,6 +108,7 @@ export * from "./functions/trinketCacheFlag";
108
108
  export * from "./functions/trinketGive";
109
109
  export * from "./functions/trinkets";
110
110
  export * from "./functions/tstlClass";
111
+ export * from "./functions/types";
111
112
  export * from "./functions/ui";
112
113
  export * from "./functions/utils";
113
114
  export * from "./functions/vector";
package/index.lua CHANGED
@@ -854,6 +854,14 @@ do
854
854
  end
855
855
  end
856
856
  end
857
+ do
858
+ local ____export = require("functions.types")
859
+ for ____exportKey, ____exportValue in pairs(____export) do
860
+ if ____exportKey ~= "default" then
861
+ ____exports[____exportKey] = ____exportValue
862
+ end
863
+ end
864
+ end
857
865
  do
858
866
  local ____export = require("functions.ui")
859
867
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "3.15.0",
3
+ "version": "3.15.3",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",