UNPKG
@typed/is-promise
Version:
latest (1.0.0)
1.0.0
Check if a value is a Promise
github.com/tylors/typed-is-promise
tylors/typed-is-promise
@typed/is-promise
/
src
/
index.ts
7 lines
(5 loc)
•
246 B
text/typescript
View Raw
1
2
3
4
5
6
7
export
function
isPromise<T>(
p
:
any
): p is
Promise
<T>;
export
function
isPromise
(
p
:
any
): p is
Promise
<
any
>;
export
function
isPromise<T>(
p
:
any
): p is
Promise
<T> {
return
p !==
null
&&
typeof
p ===
'object'
&&
typeof
p.
then
===
'function'
; }