aboutsummaryrefslogtreecommitdiffstats
path: root/util/array.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-03-31 19:01:42 +0200
committerKim Alvefur <zash@zash.se>2017-03-31 19:01:42 +0200
commit6abd0a8f1ad20e719151a4027c8ae5d1d8ba719c (patch)
treebee3cc0bc75de8d1aa4fb7ea7ca6571c449ac139 /util/array.lua
parent0646752a74aa5f7f0383000d64cd669474209d22 (diff)
parent79bc05914a516cf0d005b6adff8b264be907eaa0 (diff)
downloadprosody-6abd0a8f1ad20e719151a4027c8ae5d1d8ba719c.tar.gz
prosody-6abd0a8f1ad20e719151a4027c8ae5d1d8ba719c.zip
Merge 0.10->trunk
Diffstat (limited to 'util/array.lua')
-rw-r--r--util/array.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/util/array.lua b/util/array.lua
index 05fa97ca..150b4355 100644
--- a/util/array.lua
+++ b/util/array.lua
@@ -92,6 +92,18 @@ function array_base.sort(outa, ina, ...)
return outa;
end
+function array_base.unique(outa, ina)
+ local seen = {};
+ return array_base.filter(outa, ina, function (item)
+ if seen[item] then
+ return false;
+ else
+ seen[item] = true;
+ return true;
+ end
+ end);
+end
+
function array_base.pluck(outa, ina, key)
for i = 1, #ina do
outa[i] = ina[i][key];