mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
fix(table): regression in contains
Other changes are just whitespace.
This commit is contained in:
@@ -9,8 +9,6 @@ local pairs = pairs
|
|||||||
---@return boolean
|
---@return boolean
|
||||||
---Checks if tbl contains the given values. Only intended for simple values and unnested tables.
|
---Checks if tbl contains the given values. Only intended for simple values and unnested tables.
|
||||||
local function contains(tbl, value)
|
local function contains(tbl, value)
|
||||||
if not next(tbl) then return false end
|
|
||||||
|
|
||||||
if type(value) ~= 'table' then
|
if type(value) ~= 'table' then
|
||||||
for _, v in pairs(tbl) do
|
for _, v in pairs(tbl) do
|
||||||
if v == value then
|
if v == value then
|
||||||
@@ -21,6 +19,7 @@ local function contains(tbl, value)
|
|||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
local set = {}
|
local set = {}
|
||||||
|
|
||||||
for _, v in pairs(tbl) do
|
for _, v in pairs(tbl) do
|
||||||
set[v] = true
|
set[v] = true
|
||||||
end
|
end
|
||||||
@@ -43,6 +42,7 @@ local function table_matches(t1, t2)
|
|||||||
local tabletype1 = table.type(t1)
|
local tabletype1 = table.type(t1)
|
||||||
|
|
||||||
if not tabletype1 then return t1 == t2 end
|
if not tabletype1 then return t1 == t2 end
|
||||||
|
|
||||||
if tabletype1 ~= table.type(t2) or (tabletype1 == 'array' and #t1 ~= #t2) then
|
if tabletype1 ~= table.type(t2) or (tabletype1 == 'array' and #t1 ~= #t2) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user