From 23a3b629d6e1cf11c41f5e719e13f389545f2024 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Fri, 14 Sep 2018 13:53:13 -0700 Subject: [PATCH] Switch type marker to be a special symbol, so it's less likely to conflict --- lib/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/init.lua b/lib/init.lua index d36c585..962da61 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -74,6 +74,8 @@ local function createSymbol(name) return symbol end +local PromiseMarker = createSymbol("PromiseMarker") + local Promise = {} Promise.prototype = {} Promise.__index = Promise.prototype @@ -114,7 +116,7 @@ function Promise.new(callback) _source = debug.traceback(), -- A tag to identify us as a promise - _type = "Promise", + [PromiseMarker] = true, _status = Promise.Status.Started, @@ -245,7 +247,7 @@ function Promise.is(object) return false end - return object._type == "Promise" + return object[PromiseMarker] == true end function Promise.prototype:getStatus()