Software /
code /
prosody
Changeset
9515:2571c65b972f
util.promise: Add a string representation
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 18 Oct 2018 13:33:19 +0200 |
parents | 9514:9db707a86a25 |
children | 9516:038446c50630 |
files | util/promise.lua |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
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;