Build/Utils/isArray.lua
Reece 630939c6ac [+] JSON -> noLink
[*] Most actions can now be json objects. Evaluating lua should be the last thing we want to do from a json file
[+] Added isArray
[*] Update language to C++20 across all modules
[*] Various improvements
[*] Various bug fixes
2021-06-03 14:00:02 +01:00

23 lines
449 B
Lua

-- lua-cjson's is_array by Mark Pulford
function isArray(table)
local max = 0
local count = 0
if (type(object) ~= "table") then
return false
end
for k, v in pairs(table) do
if type(k) == "number" then
if k > max then max = k end
count = count + 1
else
return false
end
end
if max > count * 2 then
return false
end
return max > 0
end