Type Checking Tool for inspect
List of Functions
isNumber(text) => boolean
Determine if the value is of a numeric type, supporting numeric strings.
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| text | unknown | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it numeric? |
Example
import { isNumber } from '@hy-app/ui';
console.log(isNumber(123)); // true
console.log(isNumber('123')); // true
console.log(isNumber('admin')); // falseisNumericString(text) => boolean
Determine if the value is a numeric string, strictly typed as string.
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| text | string | number | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it numeric string? |
Example
import { isNumericString } from '@hy-app/ui';
console.log(isNumericString(123)); // false
console.log(isNumericString('123')); // trueisString(text) => boolean
Determine if the value is of a string type.
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| text | unknown | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it a string? |
Example
import { isString } from '@hy-app/ui';
console.log(isString(123)); // false
console.log(isString(true)); // false
console.log(isString({ name: 111 })); // false
console.log(isString('kiss')); // trueisBoolean(text) => boolean
Determine if the value is of a boolean type.
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| text | unknown | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it a boolean? |
Example
import { isBoolean } from '@hy-app/ui';
console.log(isBoolean(123)); // false
console.log(isBoolean('123')); // false
console.log(isBoolean('true')); // false
console.log(isBoolean(false)); // trueisArray(arr) => boolean
Determine if the value is of an array type.
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| arr | unknown | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it an array? |
Example
import { isArray } from '@hy-app/ui';
console.log(isArray([1, 2, 3])); // true
console.log(isArray({})); // falseisObject(obj) => boolean
Determine if the value is of an object type (excluding arrays).
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| obj | unknown | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it an object? |
Example
import { isObject } from '@hy-app/ui';
console.log(isObject([])); // false
console.log(isObject({ name: '乌沙奇' })); // trueisImage(text) => boolean
Determine if the string is an image URL.
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| text | string | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it an image URL? |
Example
import { isImage } from '@hy-app/ui';
console.log(isImage('https://example.com/image.png')); // trueisBase64Image(text) => boolean
Determine if the string is a base64 encoded image.
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| text | string | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it a base64 image? |
Example
import { isBase64Image } from '@hy-app/ui';
console.log(isBase64Image('data:image...')); // trueisVideo(text) => boolean
Determine if the string is a video URL.
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| text | string | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it a video format? |
Example
import { isVideo } from '@hy-app/ui';
console.log(isVideo('http://example.com/video.mp4')); // trueisDate(text) => boolean
Determine if the value is in date format (supports strings and timestamps).
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| text | string | number | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it a date format? |
Example
import { isDate } from '@hy-app/ui';
console.log(isDate('2024-10-10')); // true
console.log(isDate(1754032899)); // trueisPhone(text) => boolean
Determine if the value is in phone number format.
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| text | unknown | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it a phone number format? |
Example
import { isPhone } from '@hy-app/ui';
console.log(isPhone(19701012929)); // trueisIdCard(text) => boolean
Determine if the value is in ID card number format.
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| text | unknown | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it an ID card number? |
Example
import { isIdCard } from '@hy-app/ui';
console.log(isIdCard('360322201207022918')); // trueisChinese(text) => boolean
Determine if the string is composed entirely of Chinese characters.
Parameters
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| text | string | Yes | - | The value to check |
Return Value
| Type | Description |
|---|---|
| boolean | Is it all Chinese? |
Example
import { isChinese } from '@hy-app/ui';
console.log(isChinese('皇帝')); // true
console.log(isChinese('3ed皇帝')); // falseisH5() => boolean
Determine if the current runtime environment is H5.
Parameters
None
Return Value
| Type | Description |
|---|---|
| boolean | Is the current environment H5? |
Example
import { isH5 } from '@hy-app/ui';
console.log(isH5()); // true
