From: Vsevolod Stakhov Date: Thu, 13 Sep 2018 14:26:42 +0000 (+0100) Subject: [Minor] Add take_n/drop_n processing functions X-Git-Tag: 1.8.0~112 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=be68b46a9437a7e4e79f609fa0c87730e337389c;p=rspamd.git [Minor] Add take_n/drop_n processing functions --- 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'] = {