]> git.lizzy.rs Git - lua_async.git/blob - util.lua
Add source code
[lua_async.git] / util.lua
1 function lua_async.yield()
2         local co = assert(coroutine.running(), "yield called outside of an async function")
3
4         setTimeout(lua_async.resume, 0, co)
5
6         coroutine.yield()
7 end
8
9 function lua_async.sleep(ms)
10         await(Promise(function(resolve)
11                 setTimeout(resolve, ms)
12         end))
13 end