mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 20:38:22 +01:00
18 lines
422 B
Lua
18 lines
422 B
Lua
function pump.step(src, snk)
|
|
local chunk, src_err = src()
|
|
local ret, snk_err = snk(chunk, src_err)
|
|
if chunk and ret then return 1
|
|
else return nil, src_err or snk_err end
|
|
end
|
|
|
|
function pump.all(src, snk, step)
|
|
step = step or pump.step
|
|
while true do
|
|
local ret, err = step(src, snk)
|
|
if not ret then
|
|
if err then return nil, err
|
|
else return 1 end
|
|
end
|
|
end
|
|
end
|