# HG changeset patch # User Kim Alvefur # Date 1539862399 -7200 # Node ID 2571c65b972ffbd6b42f7a28d715815e913a12ba # Parent 9db707a86a258d12be7099b5353631727724f5b0 util.promise: Add a string representation diff -r 9db707a86a25 -r 2571c65b972f util/promise.lua --- 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;