Little bug in manual.
This commit is contained in:
parent
3700bf65b7
commit
bdc3e241bb
3 changed files with 27 additions and 3 deletions
|
@ -31,6 +31,7 @@ function filter.cycle(low, ctx, extra)
|
|||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
local function chain2(f1, f2)
|
||||
local ff1, ff2 = "", ""
|
||||
return function(chunk)
|
||||
|
@ -55,6 +56,29 @@ local function chain2(f1, f2)
|
|||
end
|
||||
end
|
||||
end
|
||||
]]
|
||||
|
||||
local function chain2(f1, f2)
|
||||
local co = coroutine.create(function(chunk)
|
||||
while true do
|
||||
local filtered1 = f1(chunk)
|
||||
local filtered2 = f2(filtered1)
|
||||
local done2 = filtered1 and ""
|
||||
while true do
|
||||
if filtered2 == "" or filtered2 == nil then break end
|
||||
coroutine.yield(filtered2)
|
||||
filtered2 = f2(done2)
|
||||
end
|
||||
if filtered1 == "" then chunk = coroutine.yield(filtered1)
|
||||
elseif filtered1 == nil then return nil
|
||||
else chunk = chunk and "" end
|
||||
end
|
||||
end)
|
||||
return function(chunk)
|
||||
local _, res = coroutine.resume(co, chunk)
|
||||
return res
|
||||
end
|
||||
end
|
||||
|
||||
-- chains a bunch of filters together
|
||||
function filter.chain(...)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue