Still work to do in the manual...

This commit is contained in:
Diego Nehab 2004-06-16 04:28:21 +00:00
parent 8e80e38f2c
commit 0a4c1534f3
15 changed files with 257 additions and 146 deletions

View file

@ -23,6 +23,7 @@ BLOCKSIZE = 2048
-----------------------------------------------------------------------------
-- returns a high level filter that cycles a low-level filter
function filter.cycle(low, ctx, extra)
assert(low)
return function(chunk)
local ret
ret, ctx = low(ctx, chunk, extra)
@ -32,6 +33,7 @@ end
-- chains two filters together
local function chain2(f1, f2)
assert(f1 and f2)
local co = coroutine.create(function(chunk)
while true do
local filtered1 = f1(chunk)
@ -95,6 +97,7 @@ end
-- turns a fancy source into a simple source
function source.simplify(src)
assert(src)
return function()
local chunk, err_or_new = src()
src = err_or_new or src
@ -118,6 +121,7 @@ end
-- creates rewindable source
function source.rewind(src)
assert(src)
local t = {}
return function(chunk)
if not chunk then
@ -132,6 +136,7 @@ end
-- chains a source with a filter
function source.chain(src, f)
assert(src and f)
local co = coroutine.create(function()
while true do
local chunk, err = src()
@ -186,6 +191,7 @@ end
-- turns a fancy sink into a simple sink
function sink.simplify(snk)
assert(snk)
return function(chunk, err)
local ret, err_or_new = snk(chunk, err)
if not ret then return nil, err_or_new end
@ -224,6 +230,7 @@ end
-- chains a sink with a filter
function sink.chain(f, snk)
assert(f and snk)
return function(chunk, err)
local filtered = f(chunk)
local done = chunk and ""
@ -248,6 +255,7 @@ end
-- pumps all data from a source to a sink, using a step function
function pump.all(src, snk, step)
assert(src and snk)
step = step or pump.step
while true do
local ret, err = step(src, snk)