mirror of
https://github.com/AmberGraceRblx/luau-promise.git
synced 2025-04-24 15:50:01 +00:00
Make Promise.is only check andThennable
This commit is contained in:
parent
14587cd491
commit
1a0ec7db47
3 changed files with 6 additions and 7 deletions
|
@ -1,3 +1,7 @@
|
|||
# 2.4.0
|
||||
|
||||
- `Promise.is` now only checks if the object is "andThennable" (has an `andThen` method).
|
||||
|
||||
# 2.3.1
|
||||
|
||||
- Make unhandled rejection warning trigger on next Heartbeat
|
||||
|
|
|
@ -186,7 +186,7 @@ docs:
|
|||
params: "promises: array<Promise<T>>"
|
||||
returns: Promise<T>
|
||||
- name: is
|
||||
desc: Returns whether the given object is a Promise.
|
||||
desc: Returns whether the given object is a Promise. This only checks if the object is a table and has an `andThen` method.
|
||||
static: true
|
||||
params: "object: any"
|
||||
returns:
|
||||
|
|
|
@ -67,8 +67,6 @@ local function createSymbol(name)
|
|||
return symbol
|
||||
end
|
||||
|
||||
local PromiseMarker = createSymbol("PromiseMarker")
|
||||
|
||||
local Promise = {}
|
||||
Promise.prototype = {}
|
||||
Promise.__index = Promise.prototype
|
||||
|
@ -101,9 +99,6 @@ function Promise.new(callback, parent)
|
|||
-- Used to locate where a promise was created
|
||||
_source = debug.traceback(),
|
||||
|
||||
-- A tag to identify us as a promise
|
||||
[PromiseMarker] = true,
|
||||
|
||||
_status = Promise.Status.Started,
|
||||
|
||||
-- A table containing a list of all results, whether success or failure.
|
||||
|
@ -300,7 +295,7 @@ function Promise.is(object)
|
|||
return false
|
||||
end
|
||||
|
||||
return object[PromiseMarker] == true
|
||||
return type(object.andThen) == "function"
|
||||
end
|
||||
|
||||
--[[
|
||||
|
|
Loading…
Reference in a new issue