Skip to content

Commit 97b6fae

Browse files
chore(shared): improve isPromise check in accordance with Promise A+ specification (#8506)
1 parent 736cf15 commit 97b6fae

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/shared/src/general.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ export const isObject = (val: unknown): val is Record<any, any> =>
5050
val !== null && typeof val === 'object'
5151

5252
export const isPromise = <T = any>(val: unknown): val is Promise<T> => {
53-
return isObject(val) && isFunction(val.then) && isFunction(val.catch)
53+
return (
54+
(isObject(val) || isFunction(val)) &&
55+
isFunction(val.then) &&
56+
isFunction(val.catch)
57+
)
5458
}
5559

5660
export const objectToString = Object.prototype.toString

0 commit comments

Comments
 (0)