mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-19 19:58:20 +01:00
15 lines
231 B
Lua
15 lines
231 B
Lua
|
function source.chain(src, f)
|
||
|
return function()
|
||
|
if not src then
|
||
|
return nil
|
||
|
end
|
||
|
local chunk, err = src()
|
||
|
if not chunk then
|
||
|
src = nil
|
||
|
return f(nil)
|
||
|
else
|
||
|
return f(chunk)
|
||
|
end
|
||
|
end
|
||
|
end
|