aboutsummaryrefslogtreecommitdiffstats
path: root/util/import.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-10-04 02:43:23 +0100
committerMatthew Wild <mwild1@gmail.com>2008-10-04 02:43:23 +0100
commit0f8ba47525595a9432b4060204d943cfb26bdc61 (patch)
treeac50f175795c1206b9eac2fcb2d296e6bc0196b8 /util/import.lua
parent459665b3680dde4ab4ef65d067139d7d132d96ff (diff)
downloadprosody-0f8ba47525595a9432b4060204d943cfb26bdc61.tar.gz
prosody-0f8ba47525595a9432b4060204d943cfb26bdc61.zip
New "import" module to help tidy up all the local declarations at the top of modules
Diffstat (limited to 'util/import.lua')
-rw-r--r--util/import.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/util/import.lua b/util/import.lua
new file mode 100644
index 00000000..6aab0d45
--- /dev/null
+++ b/util/import.lua
@@ -0,0 +1,13 @@
+
+local t_insert = table.insert;
+function import(module, ...)
+ local m = package.loaded[module] or require(module);
+ if type(m) == "table" and ... then
+ local ret = {};
+ for _, f in ipairs{...} do
+ t_insert(ret, m[f]);
+ end
+ return unpack(ret);
+ end
+ return m;
+end