summaryrefslogtreecommitdiffhomepage
path: root/libs/core/luasrc/util.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-08-17 14:56:03 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-08-17 14:56:03 +0000
commitc7ba7f99b04178e839f343b4f3e17cf3c18ea75a (patch)
treee1dc972bd13f53b20b6916bcdfdf78522b04e3ef /libs/core/luasrc/util.lua
parent38ef0f92e75b90e405f4879c163e9bbfbbbe293f (diff)
* luci/libs: add keys() to luci.util
Diffstat (limited to 'libs/core/luasrc/util.lua')
-rw-r--r--libs/core/luasrc/util.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua
index ef1b8fe27..c6d9ec6ce 100644
--- a/libs/core/luasrc/util.lua
+++ b/libs/core/luasrc/util.lua
@@ -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