# 判断
- 环境判断
export declare const isProd: boolean;
export declare const getEnv: () => {
isiOS: boolean;
isIOS: boolean;
isAndroid: boolean;
isQQ: boolean;
isWechat: boolean;
isMSDK: boolean;
isSlugSDK: boolean;
env: {
device: string;
platform: string;
sdk: string;
};
};
export declare const isMSDKV3: ({ search, hash }: Location) => boolean;
export declare const isMSDKV5: ({ search, hash }: Location) => boolean;
export declare const webpCheck: () => Promise<boolean>;
export declare const isSupportWebp: () => boolean;
重要更新:出于 tree-shacking 的考量,停止使用立即计算结果的方式,替换方法如下:
// 旧
import { isSlugSDK } from '@tencent/slug-function'
// 新
import { getEnv } from '@tencent/slug-function'
const { isSlugSDK } = getEnv()
- 类型判断
export declare const getType: (value: any) => string;
export declare function isObject(obj: any): obj is Object;
export declare function isRegExp(v: any): v is RegExp;
export declare const isFunction: (value: any) => value is Function;
export declare const isSymbol: (value: any) => value is Symbol;
export declare const isArray: <T = any>(value: any) => value is T[];
export declare const isNumber: (value: any) => value is Number;
export declare const isBoolean: (value: any) => value is Boolean;
export declare const isString: (value: any) => value is String;
export declare const isDate: (value: any) => value is Date;
export declare const isPromise: <T = any>(value: any) => value is Promise<T>;
export declare const isEmpty: (value: any) => boolean;
export declare const isNotEmpty: (value: any) => boolean;
export declare const isEmptyString: (s: string) => boolean;
- checkIfNeedUpdate
检查是否需要更新
定义:
/**
* 检查是否需要更新
* @param currentVersion 当前版本
* @param remoteVersion 最新版本
*/
export declare function checkIfNeedUpdate(currentVersion: string, remoteVersion: string): boolean;