mirror of
https://github.com/AmberGraceRblx/luau-promise.git
synced 2025-04-24 23:50:03 +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
|
# 2.3.1
|
||||||
|
|
||||||
- Make unhandled rejection warning trigger on next Heartbeat
|
- Make unhandled rejection warning trigger on next Heartbeat
|
||||||
|
|
|
@ -186,7 +186,7 @@ docs:
|
||||||
params: "promises: array<Promise<T>>"
|
params: "promises: array<Promise<T>>"
|
||||||
returns: Promise<T>
|
returns: Promise<T>
|
||||||
- name: is
|
- 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
|
static: true
|
||||||
params: "object: any"
|
params: "object: any"
|
||||||
returns:
|
returns:
|
||||||
|
|
|
@ -67,8 +67,6 @@ 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
|
||||||
|
@ -101,9 +99,6 @@ function Promise.new(callback, parent)
|
||||||
-- Used to locate where a promise was created
|
-- Used to locate where a promise was created
|
||||||
_source = debug.traceback(),
|
_source = debug.traceback(),
|
||||||
|
|
||||||
-- A tag to identify us as a promise
|
|
||||||
[PromiseMarker] = true,
|
|
||||||
|
|
||||||
_status = Promise.Status.Started,
|
_status = Promise.Status.Started,
|
||||||
|
|
||||||
-- A table containing a list of all results, whether success or failure.
|
-- A table containing a list of all results, whether success or failure.
|
||||||
|
@ -300,7 +295,7 @@ function Promise.is(object)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return object[PromiseMarker] == true
|
return type(object.andThen) == "function"
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|
Loading…
Reference in a new issue