mirror of
https://github.com/AmberGraceRblx/luau-promise.git
synced 2025-04-24 23:50:03 +00:00
Switch type marker to be a special symbol, so it's less likely to conflict
This commit is contained in:
parent
9bda3e68ea
commit
23a3b629d6
1 changed files with 4 additions and 2 deletions
|
@ -74,6 +74,8 @@ local function createSymbol(name)
|
||||||
return symbol
|
return symbol
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local PromiseMarker = createSymbol("PromiseMarker")
|
||||||
|
|
||||||
local Promise = {}
|
local Promise = {}
|
||||||
Promise.prototype = {}
|
Promise.prototype = {}
|
||||||
Promise.__index = Promise.prototype
|
Promise.__index = Promise.prototype
|
||||||
|
@ -114,7 +116,7 @@ function Promise.new(callback)
|
||||||
_source = debug.traceback(),
|
_source = debug.traceback(),
|
||||||
|
|
||||||
-- A tag to identify us as a promise
|
-- A tag to identify us as a promise
|
||||||
_type = "Promise",
|
[PromiseMarker] = true,
|
||||||
|
|
||||||
_status = Promise.Status.Started,
|
_status = Promise.Status.Started,
|
||||||
|
|
||||||
|
@ -245,7 +247,7 @@ function Promise.is(object)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return object._type == "Promise"
|
return object[PromiseMarker] == true
|
||||||
end
|
end
|
||||||
|
|
||||||
function Promise.prototype:getStatus()
|
function Promise.prototype:getStatus()
|
||||||
|
|
Loading…
Reference in a new issue