Merge 0.10->trunk
[prosody.git] / util / import.lua
1 -- Prosody IM
2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 --
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
8
9
10
11 local unpack = table.unpack or unpack; --luacheck: ignore 113
12 local t_insert = table.insert;
13 function import(module, ...)
14         local m = package.loaded[module] or require(module);
15         if type(m) == "table" and ... then
16                 local ret = {};
17                 for _, f in ipairs{...} do
18                         t_insert(ret, m[f]);
19                 end
20                 return unpack(ret);
21         end
22         return m;
23 end