aboutsummaryrefslogtreecommitdiffstats
path: root/util/array.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-08-08 11:49:31 +0100
committerMatthew Wild <mwild1@gmail.com>2012-08-08 11:49:31 +0100
commita3c13a5074a5b2967402be5a4d29408714940289 (patch)
tree9fa3eea4bf32bd9c0dba7aa776e2482bdc1d3748 /util/array.lua
parentec30ac5f17a930796e5c829637c7f57e8727e922 (diff)
downloadprosody-a3c13a5074a5b2967402be5a4d29408714940289.tar.gz
prosody-a3c13a5074a5b2967402be5a4d29408714940289.zip
util.array: Accept an iterator to the array constructor
Diffstat (limited to 'util/array.lua')
-rw-r--r--util/array.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/util/array.lua b/util/array.lua
index 5dc604ba..b78fb98f 100644
--- a/util/array.lua
+++ b/util/array.lua
@@ -19,7 +19,10 @@ local array_base = {};
local array_methods = {};
local array_mt = { __index = array_methods, __tostring = function (array) return array:concat(", "); end };
-local function new_array(_, t)
+local function new_array(self, t, _s, _var)
+ if type(t) == "function" then -- Assume iterator
+ t = self.collect(t, _s, _var);
+ end
return setmetatable(t or {}, array_mt);
end