diff --git a/imports/mysql/server.lua b/imports/mysql/server.lua index 91bc083..0dc236b 100644 --- a/imports/mysql/server.lua +++ b/imports/mysql/server.lua @@ -1,3 +1,7 @@ +--------------------------------------------------------------------------- +--- MySQL-Async like library for OxMySQL, without the function name aliases +--------------------------------------------------------------------------- + local MySQL = {} MySQL.ready = function(cb) diff --git a/imports/table/shared.lua b/imports/table/shared.lua new file mode 100644 index 0000000..b70792a --- /dev/null +++ b/imports/table/shared.lua @@ -0,0 +1,53 @@ +---------------------------------------------------------- +--- Add additional functions to the standard table library +---------------------------------------------------------- + +local table = table +local pairs = pairs + +local function contains(tbl, value) + if type(value) == 'string' then + for _, v in pairs(tbl) do + if v == value then return true end + end + else + local matched_values = 0 + local values = 0 + for _, v1 in pairs(value) do + values += 1 + + for _, v2 in pairs(tbl) do + if v1 == v2 then matched_values += 1 end + end + end + if matched_values == values then return true end + end + return false +end +table.contains = contains + +local function match(t1, t2) + if t1 == t2 then return true end + if type(t1) ~= 'table' then return false end + + local matched_values = 0 + local values = 0 + + for _, v in pairs(t1) do + values += 1 + if type(t2) == 'table' then + for _, v2 in pairs(t2) do + if v == v2 then + matched_values += 1 + elseif match(v, v2) then + values += 1 + matched_values += #v + end + end + elseif v == t2 then matched_values += 1 end + end + return matched_values == values +end +table.match = match + +return table \ No newline at end of file