Add dynamic local network api

This commit is contained in:
emanuele-f 2017-12-21 17:18:49 +01:00
parent 204246583d
commit 42ab649693
4 changed files with 38 additions and 3 deletions

View file

@ -3062,9 +3062,22 @@ function table.clone(t, filter)
return clone
end
function table.deepcopy(t)
local json = require("dkjson")
return json.decode(json.encode(t))
-- TODO join the code with table.clone
function table.deepcopy(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[table.deepcopy(orig_key)] = table.deepcopy(orig_value)
end
setmetatable(copy, table.deepcopy(getmetatable(orig)))
else -- number, string, boolean, etc
copy = orig
end
return copy
end
function toboolean(s)