1
0
mirror of https://github.com/tacigar/maidroid.git synced 2024-11-15 14:50:22 +01:00
maidroid/util.lua

24 lines
577 B
Lua
Raw Normal View History

2016-05-31 06:26:54 +02:00
------------------------------------------------------------
-- Copyright (c) 2016 tacigar
-- https://github.com/tacigar/maidroid
------------------------------------------------------------
maidroid.util = {}
2016-06-02 06:18:58 +02:00
-- check that the table has the value
2016-05-31 06:26:54 +02:00
function maidroid.util.table_find_value(tbl, value)
for k, v in ipairs(tbl) do
if v == value then return true, k end
end
return false, nil
end
2016-06-02 06:18:58 +02:00
-- table shallow copy
2016-05-31 06:26:54 +02:00
function maidroid.util.table_shallow_copy(source)
local copy = {}
for key, value in pairs(source) do
copy[key] = value
end
return copy
end