first commit

This commit is contained in:
2021-12-18 20:10:30 +01:00
parent 4d04f63b99
commit 215bed9faf
108 changed files with 3630 additions and 0 deletions

31
lib/knife/chain.lua Normal file
View File

@@ -0,0 +1,31 @@
local function Invoker (links, index)
return function (...)
local link = links[index]
if not link then
return
end
local continue = Invoker(links, index + 1)
local returned = link(continue, ...)
if returned then
returned(function (_, ...) continue(...) end)
end
end
end
return function (...)
local links = { ... }
local function chain (...)
if not (...) then
return Invoker(links, 1)(select(2, ...))
end
local offset = #links
for index = 1, select('#', ...) do
links[offset + index] = select(index, ...)
end
return chain
end
return chain
end