From: 丶远方 Date: Tue, 11 Jul 2023 09:41:09 +0000 (+0800) Subject: chore(shared): improve isPromise check in accordance with Promise A+ specification... X-Git-Tag: v3.3.5~64 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=97b6fae6b477d5b1a95e94963667e171e16d5410;p=thirdparty%2Fvuejs%2Fcore.git chore(shared): improve isPromise check in accordance with Promise A+ specification (#8506) --- diff --git a/packages/shared/src/general.ts b/packages/shared/src/general.ts index 4138b2730e..59a1e911b6 100644 --- a/packages/shared/src/general.ts +++ b/packages/shared/src/general.ts @@ -50,7 +50,11 @@ export const isObject = (val: unknown): val is Record => val !== null && typeof val === 'object' export const isPromise = (val: unknown): val is Promise => { - 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