Software / code / prosody
Diff
util/promise.lua @ 9515:2571c65b972f
util.promise: Add a string representation
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 18 Oct 2018 13:33:19 +0200 |
| parent | 9514:9db707a86a25 |
| child | 9517:b1c6ede17592 |
line wrap: on
line diff
--- a/util/promise.lua Thu Oct 18 12:13:17 2018 +0100 +++ b/util/promise.lua Thu Oct 18 13:33:19 2018 +0200 @@ -1,6 +1,10 @@ local promise_methods = {}; local promise_mt = { __name = "promise", __index = promise_methods }; +function promise_mt:__tostring() + return "promise (" .. (self._state or "invalid") .. ")"; +end + local function is_promise(o) local mt = getmetatable(o); return mt == promise_mt;