Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: