luci.util.combine now also accepts single objects
This commit is contained in:
parent
b202a403ff
commit
8d9a130b70
1 changed files with 8 additions and 4 deletions
|
@ -320,16 +320,20 @@ function parse_units(ustr)
|
||||||
return val
|
return val
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Combines two or more numerically indexed tables into one.
|
--- Combines two or more numerically indexed tables and single objects into one table.
|
||||||
-- @param tbl1 Table value to combine
|
-- @param tbl1 Table value to combine
|
||||||
-- @param tbl2 Table value to combine
|
-- @param tbl2 Table value to combine
|
||||||
-- @param ... More tables to combine
|
-- @param ... More tables to combine
|
||||||
-- @return Table value containing all values of given tables
|
-- @return Table value containing all values of given tables
|
||||||
function combine(...)
|
function combine(...)
|
||||||
local result = {}
|
local result = {}
|
||||||
for i, a in ipairs(arg) do
|
for i, a in ipairs({...}) do
|
||||||
for j, v in ipairs(a) do
|
if type(a) == "table" then
|
||||||
result[#result+1] = v
|
for j, v in ipairs(a) do
|
||||||
|
result[#result+1] = v
|
||||||
|
end
|
||||||
|
else
|
||||||
|
result[#result+1] = a
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in a new issue