cxc-szcx-uniapp/uni_modules/lime-shared/isNumber/index.ts
2025-02-11 17:09:35 +08:00

26 lines
920 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// @ts-nocheck
/**
* 检查一个值是否为数字类型
* @param value 要检查的值,可以是 number 类型或 string 类型的数字
* @returns 如果值是数字类型且不是 NaN则返回 true否则返回 false
*/
// #ifndef UNI-APP-X
export function isNumber(value: number | string | null): boolean {
return typeof value === 'number' && !isNaN(value);
}
// #endif
// #ifdef UNI-APP-X
export function isNumber(value: any|null): boolean {
// #ifdef APP-ANDROID
return ['Byte', 'UByte','Short','UShort','Int','UInt','Long','ULong','Float','Double','number'].includes(typeof value)
// #endif
// #ifdef APP-IOS
return ['Int8', 'UInt8','Int16','UInt16','Int32','UInt32','Int64','UInt64','Int','UInt','Float','Float16','Float32','Float64','Double', 'number'].includes(typeof value)
// #endif
// #ifndef UNI-APP-X && APP
return typeof value === 'number' && !isNaN(value);
// #endif
}
// #endif