isaacscript-common 1.2.198 → 1.2.199
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.
|
@@ -123,4 +123,4 @@ export declare function repeat(n: int, func: (i: int) => void): void;
|
|
|
123
123
|
* Helper function to check every value of a custom enum for -1. This is helpful as a run-time check
|
|
124
124
|
* because many methods of the Isaac class return -1 if they fail.
|
|
125
125
|
*/
|
|
126
|
-
export declare function validateCustomEnum(
|
|
126
|
+
export declare function validateCustomEnum(transpiledEnumName: string, transpiledEnum: unknown): void;
|
package/dist/functions/utils.lua
CHANGED
|
@@ -4,6 +4,7 @@ local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
|
4
4
|
local __TS__StringReplace = ____lualib.__TS__StringReplace
|
|
5
5
|
local __TS__StringSubstr = ____lualib.__TS__StringSubstr
|
|
6
6
|
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
7
|
+
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
7
8
|
local ____exports = {}
|
|
8
9
|
local ____directionNames = require("objects.directionNames")
|
|
9
10
|
local DIRECTION_NAMES = ____directionNames.DIRECTION_NAMES
|
|
@@ -77,18 +78,21 @@ ____exports["repeat"] = function(self, n, func)
|
|
|
77
78
|
end
|
|
78
79
|
end
|
|
79
80
|
end
|
|
80
|
-
function ____exports.validateCustomEnum(self,
|
|
81
|
-
local customEnumType = type(
|
|
81
|
+
function ____exports.validateCustomEnum(self, transpiledEnumName, transpiledEnum)
|
|
82
|
+
local customEnumType = type(transpiledEnum)
|
|
82
83
|
if customEnumType ~= "table" then
|
|
83
84
|
return
|
|
84
85
|
end
|
|
85
|
-
local ____table =
|
|
86
|
-
local keys =
|
|
86
|
+
local ____table = transpiledEnum
|
|
87
|
+
local keys = __TS__ArrayFilter(
|
|
88
|
+
__TS__ObjectKeys(____table),
|
|
89
|
+
function(____, key) return type(key) == "string" end
|
|
90
|
+
)
|
|
87
91
|
__TS__ArraySort(keys)
|
|
88
92
|
for ____, key in ipairs(keys) do
|
|
89
93
|
local value = ____table[key]
|
|
90
94
|
if value == -1 then
|
|
91
|
-
error((("Failed to find: " ..
|
|
95
|
+
error((("Failed to find: " .. transpiledEnumName) .. ".") .. key)
|
|
92
96
|
end
|
|
93
97
|
end
|
|
94
98
|
end
|