summaryrefslogtreecommitdiffhomepage
path: root/libs/core/luasrc
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-10-30 19:10:22 +0000
committerSteven Barth <steven@midlink.org>2008-10-30 19:10:22 +0000
commit8d9a130b70b532bff0ffd01b81481a040c25a53b (patch)
treef1a260436b89e2f172d8ad323bc55fffd19cd13a /libs/core/luasrc
parentb202a403ff38453c978c7ad0d972525cd81c7b99 (diff)
luci.util.combine now also accepts single objects
Diffstat (limited to 'libs/core/luasrc')
-rw-r--r--libs/core/luasrc/util.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua
index 77c763d14..6498a4976 100644
--- a/libs/core/luasrc/util.lua
+++ b/libs/core/luasrc/util.lua
@@ -320,16 +320,20 @@ function parse_units(ustr)
return val
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 tbl2 Table value to combine
-- @param ... More tables to combine
-- @return Table value containing all values of given tables
function combine(...)
local result = {}
- for i, a in ipairs(arg) do
- for j, v in ipairs(a) do
- result[#result+1] = v
+ for i, a in ipairs({...}) do
+ if type(a) == "table" then
+ for j, v in ipairs(a) do
+ result[#result+1] = v
+ end
+ else
+ result[#result+1] = a
end
end
return result