Merge 0.10->trunk
[prosody.git] / util / multitable.lua
index caf25118e3f622ecd66dbea06b5c24de7abba968..e4321d3d34e120e8740b1db80278cabdbbe93e3d 100644 (file)
@@ -8,9 +8,10 @@
 
 local select = select;
 local t_insert = table.insert;
-local unpack, pairs, next, type = unpack, pairs, next, type;
+local pairs, next, type = pairs, next, type;
+local unpack = table.unpack or unpack; --luacheck: ignore 113
 
-module "multitable"
+local _ENV = nil;
 
 local function get(self, ...)
        local t = self.data;
@@ -126,7 +127,7 @@ local function search_add(self, results, ...)
        return results;
 end
 
-function iter(self, ...)
+local function iter(self, ...)
        local query = { ... };
        local maxdepth = select("#", ...);
        local stack = { self.data };
@@ -161,7 +162,7 @@ function iter(self, ...)
        return it, self;
 end
 
-function new()
+local function new()
        return {
                data = {};
                get = get;
@@ -174,4 +175,7 @@ function new()
        };
 end
 
-return _M;
+return {
+       iter = iter;
+       new = new;
+};