diff --git a/Useful Modules/Util/Math.lua b/Useful Modules/Util/Math.lua index 35855eb..d5571a2 100644 --- a/Useful Modules/Util/Math.lua +++ b/Useful Modules/Util/Math.lua @@ -18,13 +18,13 @@ function Math.InverseLerp(a: number, b: number, value: number): number end --- @todo -function Math.IsInfNaN(...: number): boolean +function Math.IsReal(...: number): boolean for _, num in {...} do - if num == math.huge or num == -math.huge or num ~= num then - return true + if num * 0 ~= 0 then + return false end end - return false + return true end --- @todo diff --git a/Useful Modules/Util/UniqueIds.lua b/Useful Modules/Util/UniqueIds.lua index e1752bb..f728465 100644 --- a/Useful Modules/Util/UniqueIds.lua +++ b/Useful Modules/Util/UniqueIds.lua @@ -49,7 +49,7 @@ function UniqueIds.new(bytes: number, b93: boolean?, idsInUse: {string}?): Uniqu end return { - GetNewId = function(_self: UniqueIds): string + GetNewId = function(self: UniqueIds): string if numUnusedIds > 0 then local id = table.remove(unusedIds, numUnusedIds) :: string numUnusedIds -= 1 @@ -71,12 +71,21 @@ function UniqueIds.new(bytes: number, b93: boolean?, idsInUse: {string}?): Uniqu return false end; - GetIdIndex = function(_self: UniqueIds, id: string): number + GetIdIndex = function(self: UniqueIds, id: string): number return if b93 then Base93.B93ToInt(id) else string.unpack("I" .. bytes, id) - end + end; } end +--- Returns the index of a unique ID string. +--- @param bytes -- The length of the string. +--- @param id -- The unique ID string. +--- @param b93 -- Whether or not to use the Base93 format. +--- @return number -- The index of the unique ID string. +function UniqueIds:GetIdIndex(bytes: number, id: string, b93: boolean?): number + return if b93 then Base93.B93ToInt(id) else string.unpack("I" .. bytes, id) +end + -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- return UniqueIds diff --git a/selene.toml b/selene.toml index 560cd81..f14b2b4 100644 --- a/selene.toml +++ b/selene.toml @@ -31,5 +31,4 @@ unused_variable = "warn" [config] shadowing = { ignore_pattern = "^self$|^_" } -unscoped_variables = { ignore_pattern = "^self$" } -unused_variable = { allow_unused_self = true } \ No newline at end of file +unused_variable = { ignore_pattern = "^self$|^_", allow_unused_self = true } \ No newline at end of file