* luci/libs: add keys() to luci.util
This commit is contained in:
parent
38ef0f92e7
commit
c7ba7f99b0
1 changed files with 13 additions and 0 deletions
|
@ -358,6 +358,19 @@ function update(t, updates)
|
|||
end
|
||||
end
|
||||
|
||||
--- Retrieve all keys of given associative table.
|
||||
-- @param t Table to extract keys from
|
||||
-- @return Sorted table containing the keys
|
||||
function keys(t)
|
||||
local keys = { }
|
||||
if t then
|
||||
for k, _ in kspairs(t) do
|
||||
table.insert( keys, k )
|
||||
end
|
||||
end
|
||||
return keys
|
||||
end
|
||||
|
||||
--- Clones the given object and return it's copy.
|
||||
-- @param object Table value to clone
|
||||
-- @param deep Boolean indicating whether to do recursive cloning
|
||||
|
|
Loading…
Reference in a new issue