合同小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
707 B

  1. // @ts-nocheck
  2. import {isFunction} from '../isFunction'
  3. import {isObject} from '../isObject'
  4. /**
  5. * Promise
  6. * @param val
  7. * @returns Promise true false
  8. */
  9. // #ifndef APP-ANDROID
  10. export const isPromise = <T = any>(val: unknown): val is Promise<T> => {
  11. // 使用 isObject 函数判断值是否为对象类型
  12. // 使用 isFunction 函数判断值是否具有 then 方法和 catch 方法
  13. return isObject(val) && isFunction(val.then) && isFunction(val.catch);
  14. };
  15. // #endif
  16. // #ifdef APP-ANDROID
  17. export const isPromise = (val: any): boolean => {
  18. return val instanceof Promise<unknown>
  19. };
  20. // #endif