summaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-09-13 15:26:42 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-09-13 15:26:42 +0100
commitbe68b46a9437a7e4e79f609fa0c87730e337389c (patch)
tree120fae5a781d1eecc186986937f0161c33d35356 /lualib
parent5c78058e6eb6e303e27056d6cb338a22fadbab18 (diff)
downloadrspamd-be68b46a9437a7e4e79f609fa0c87730e337389c.tar.gz
rspamd-be68b46a9437a7e4e79f609fa0c87730e337389c.zip
[Minor] Add take_n/drop_n processing functions
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_selectors.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua
index 66f2906d1..cef2d163f 100644
--- a/lualib/lua_selectors.lua
+++ b/lualib/lua_selectors.lua
@@ -329,6 +329,24 @@ local transform_function = {
end,
['description'] = 'Returns the nth element',
},
+ ['take_n'] = {
+ ['types'] = {
+ ['list'] = true,
+ },
+ ['process'] = function(inp, t, args)
+ return fun.take_n(tonumber(args[1]) or 1, inp),t
+ end,
+ ['description'] = 'Returns the n first elements',
+ },
+ ['drop_n'] = {
+ ['types'] = {
+ ['list'] = true,
+ },
+ ['process'] = function(inp, t, args)
+ return fun.drop_n(tonumber(args[1]) or 1, inp),t
+ end,
+ ['description'] = 'Returns list without the first n elements',
+ },
-- Joins strings into a single string using separator in the argument
['join'] = {
['types'] = {