Skip to content

Instantly share code, notes, and snippets.

@creationix
Created August 31, 2012 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creationix/4af628ad6a8d02ad0f65 to your computer and use it in GitHub Desktop.
Save creationix/4af628ad6a8d02ad0f65 to your computer and use it in GitHub Desktop.
newFiber(function (wait, await)
local input = __filename
local output = __filename .. ".out2"
local readable = fs.ReadStream:new(await(fs.open(input, "r")))
local writable = fs.WriteStream:new(await(fs.open(output, "w")))
repeat
local chunk = await(readable:read())
p{"chunk", chunk}
await(writable:write(chunk))
until not chunk
p("done2")
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment