42 lines
734 B
Lua
42 lines
734 B
Lua
local util = {}
|
|
|
|
function util.deepEqual(a, b)
|
|
local varType = type(a)
|
|
if varType ~= type(b) then
|
|
return false
|
|
end
|
|
|
|
if varType == "table" then
|
|
for key,_ in pairs(b) do
|
|
if a[key] == nil then
|
|
return false
|
|
end
|
|
end
|
|
|
|
for key,value in pairs(a) do
|
|
if not util.deepEqual(value, b[key]) then
|
|
return false
|
|
end
|
|
end
|
|
|
|
return true
|
|
end
|
|
|
|
return a == b
|
|
end
|
|
|
|
function util.find(array, f)
|
|
for k,v in pairs(array) do
|
|
if f(v, k) then
|
|
return v
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
function util.isEmpty(tbl)
|
|
local next, t = pairs(tbl)
|
|
return next(t) == nil
|
|
end
|
|
|
|
return util |