ex10.lua 422 B

1234567891011121314151617
  1. function pump.step(src, snk)
  2. local chunk, src_err = src()
  3. local ret, snk_err = snk(chunk, src_err)
  4. if chunk and ret then return 1
  5. else return nil, src_err or snk_err end
  6. end
  7. function pump.all(src, snk, step)
  8. step = step or pump.step
  9. while true do
  10. local ret, err = step(src, snk)
  11. if not ret then
  12. if err then return nil, err
  13. else return 1 end
  14. end
  15. end
  16. end