aboutsummaryrefslogtreecommitdiff
path: root/util.lua
blob: c4067f11f36eb6fe92c66f5fa0fad6e4f2ad0e63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
function lua_async.yield()
	local co = assert(coroutine.running(), "yield called outside of an async function")

	setTimeout(lua_async.resume, 0, co)

	coroutine.yield()
end

function lua_async.sleep(ms)
	await(Promise(function(resolve)
		setTimeout(resolve, ms)
	end))
end