Skip to content

Commit

Permalink
chore(shared): improve isPromise check in accordance with Promise A+ …
Browse files Browse the repository at this point in the history
…specification (#8506)
  • Loading branch information
Alfred-Skyblue authored Jul 11, 2023
1 parent 736cf15 commit 97b6fae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/shared/src/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ export const isObject = (val: unknown): val is Record<any, any> =>
val !== null && typeof val === 'object'

export const isPromise = <T = any>(val: unknown): val is Promise<T> => {
return isObject(val) && isFunction(val.then) && isFunction(val.catch)
return (
(isObject(val) || isFunction(val)) &&
isFunction(val.then) &&
isFunction(val.catch)
)
}

export const objectToString = Object.prototype.toString
Expand Down

0 comments on commit 97b6fae

Please sign in to comment.