Files
admin-vben5/packages/utils/src/helpers/safe.ts

11 lines
341 B
TypeScript
Raw Normal View History

2025-06-18 11:03:42 +08:00
/**
*
* Number.isSafeInteger形参只能为Number类型 false
* @param str
* @returns number类型
*/
export function safeParseNumber(str: string): number | string {
const num = Number(str);
return Number.isSafeInteger(num) ? num : str;
}