2007-10-11 21:16:28 +00:00
|
|
|
local function chainpair(f1, f2)
|
|
|
|
return function(chunk)
|
|
|
|
local ret = f2(f1(chunk))
|
|
|
|
if chunk then return ret
|
|
|
|
else return (ret or "") .. (f2() or "") end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function filter.chain(...)
|
2022-03-18 12:12:39 +01:00
|
|
|
local f = select(1, ...)
|
2007-10-11 21:16:28 +00:00
|
|
|
for i = 2, select('#', ...) do
|
|
|
|
f = chainpair(f, select(i, ...))
|
|
|
|
end
|
|
|
|
return f
|
|
|
|
end
|