| | |
| | | import { isEmpty } from 'lodash-es'; |
| | | |
| | | /* |
| | | * @Description: file content |
| | | * @Author: your name |
| | | * @version: |
| | | * @Date: 2024-06-17 14:51:26 |
| | | * @LastEditors: your name |
| | | * @LastEditTime: 2024-06-17 15:43:58 |
| | | * @LastEditors: Ben Lin |
| | | * @LastEditTime: 2024-08-28 21:38:19 |
| | | */ |
| | | export { |
| | | isArguments, |
| | |
| | | isMatchWith, |
| | | isNative, |
| | | isNil, |
| | | isNumber, |
| | | isNull, |
| | | isObjectLike, |
| | | isPlainObject, |
| | |
| | | return regex.test(str); |
| | | } |
| | | |
| | | export function isNumber(str: string): boolean{ |
| | | const regex = /^[0-9]*$/; |
| | | return regex.test(str); |
| | | } |
| | | |
| | | |
| | | export function isTimeViaRegExp8601(value: any): boolean { |
| | | return /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(value.toString()); |
| | |
| | | } |
| | | |
| | | export function isNullOrEmpty(val: unknown): val is null | undefined { |
| | | return isNullOrUnDef(val) || isEmpty(val); |
| | | return isNullOrUnDef(val) || isEmpty2(val); |
| | | } |
| | | |
| | | export function isEmpty2(value: any): boolean { |
| | | if (value === null || value === undefined) { |
| | | return true; |
| | | } |
| | | if (typeof value === 'string' && value.trim() === '') { |
| | | return true; |
| | | } |
| | | if (Array.isArray(value) && value.length === 0) { |
| | | return true; |
| | | } |
| | | if (typeof value === 'object' && value !== null && Object.keys(value).length === 0) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | export function ActionToJson(action: any): any { |
| | | return JSON.parse(JSON.stringify(action)) |
| | | } |
| | | |
| | | |