4 ms·
promise map? do you mean setmetatable({}, {__index = function(tab, key) local co = coroutine.running() uv.read(fd, function(err, resul
by samatman 4y ago
promise map?
do you mean
setmetatable({}, {__index = function(tab, key)
local co = coroutine.running()
uv.read(fd, function(err, result)
tab[key] = result
return coroutine.resume(result)
end)
return coroutine.yield()
end })
This is an incomplete implementation, clearly: but I've never missed Promises with coroutines and libuv.