Module: base
Table of contents
Variables
Functions
- AES
- MD5
- RSA
- arrayToMap
- base64
- dateFormat
- dedupArray
- delay
- isCarNo
- isDef
- isEmail
- isIdCardNo
- isMobilePhone
- isUrl
- mapToObject
- now
- numberFormat
- omit
- pick
- random
- timestamp
- toArray
- toFixed
- toRawType
- toTypeString
- trim
- uid
- unAES
- unBase64
- unRSA
- upperFirstCamelCase
- uuid
- zipObject
Variables
rCar
• Const
rCar: RegExp
车牌号码表达式
Defined in
packages/base/src/regex.ts:25
rEmail
• Const
rEmail: RegExp
邮箱地址表达式
Defined in
packages/base/src/regex.ts:9
rID
• Const
rID: RegExp
身份证号码表达式
Defined in
packages/base/src/regex.ts:14
rMobile
• Const
rMobile: RegExp
手机号码表达式
Defined in
packages/base/src/regex.ts:20
rURL
• Const
rURL: RegExp
url表达式
Defined in
packages/base/src/regex.ts:4
Functions
AES
▸ AES(content
, key
): string
对称加密
Parameters
Name | Type |
---|---|
content | string |
key | string |
Returns
string
Defined in
packages/base/src/crypto.ts:78
MD5
▸ MD5(content
): string
MD5加密
Parameters
Name | Type |
---|---|
content | string |
Returns
string
Defined in
packages/base/src/crypto.ts:24
RSA
▸ RSA(content
, key?
): string
| false
非对称加密
Parameters
Name | Type | Default value | Description |
---|---|---|---|
content | string | undefined | 内容 |
key | string | RSA_PUBLIC_KEY | 公钥 |
Returns
string
| false
Description
RSA密钥对生成工具
Defined in
packages/base/src/crypto.ts:54
arrayToMap
▸ arrayToMap<T
>(data
, prop
): Map
<any
, T
>
数组转Map
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
data | T [] |
prop | keyof T |
Returns
Map
<any
, T
>
Defined in
packages/base/src/data.ts:7
base64
▸ base64(content
): string
Base64编码
Parameters
Name | Type |
---|---|
content | string |
Returns
string
Defined in
packages/base/src/crypto.ts:33
dateFormat
▸ dateFormat(date
, format?
): string
Parameters
Name | Type | Default value |
---|---|---|
date | string | number | Date | undefined |
format | string | 'YYYY-MM-DD HH:mm:ss' |
Returns
string
Defined in
packages/base/src/day.ts:6
dedupArray
▸ dedupArray<T
>(array
, prop?
): T
[]
数组去重
Type parameters
Name | Type |
---|---|
T | any |
Parameters
Name | Type |
---|---|
array | T [] |
prop? | keyof T |
Returns
T
[]
Defined in
packages/base/src/data.ts:33
delay
▸ delay(val?
): Promise
<unknown
>
延时函数
Parameters
Name | Type | Default value |
---|---|---|
val | number | 0 |
Returns
Promise
<unknown
>
Defined in
packages/base/src/util.ts:76
isCarNo
▸ isCarNo(content
): boolean
检查车牌号码
Parameters
Name | Type |
---|---|
content | string |
Returns
boolean
Defined in
packages/base/src/regex.ts:69
isDef
▸ isDef(val
): boolean
已定义
Parameters
Name | Type |
---|---|
val | unknown |
Returns
boolean
Defined in
packages/base/src/util.ts:18
isEmail
▸ isEmail(content
): boolean
检查邮箱地址
Parameters
Name | Type |
---|---|
content | string |
Returns
boolean
Defined in
packages/base/src/regex.ts:42
isIdCardNo
▸ isIdCardNo(content
): boolean
检查身份证号码
Parameters
Name | Type |
---|---|
content | string |
Returns
boolean
Defined in
packages/base/src/regex.ts:51
isMobilePhone
▸ isMobilePhone(content
): boolean
检查手机号码
Parameters
Name | Type |
---|---|
content | string |
Returns
boolean
Defined in
packages/base/src/regex.ts:60
isUrl
▸ isUrl(content
): boolean
检查url
Parameters
Name | Type |
---|---|
content | string |
Returns
boolean
Defined in
packages/base/src/regex.ts:33
mapToObject
▸ mapToObject<V
>(map
): Record
<any
, V
>
Map转键值对
Type parameters
Name | Type |
---|---|
V | any |
Parameters
Name | Type |
---|---|
map | Map <any , V > |
Returns
Record
<any
, V
>
Defined in
packages/base/src/data.ts:20
now
▸ now(): number
当前时间
Returns
number
Defined in
packages/base/src/util.ts:24
numberFormat
▸ numberFormat(value
, format?
): string
数字格式化,默认2位小数
Parameters
Name | Type | Default value |
---|---|---|
value | number | undefined |
format | string | '0.00' |
Returns
string
Defined in
packages/base/src/numeral.ts:9
omit
▸ omit<T
, K
>(target
, keys
): K
对象排除属性
Type parameters
Name | Type |
---|---|
T | extends Record <string , any > |
K | extends Record <string , any > |
Parameters
Name | Type | Description |
---|---|---|
target | T | 需要处理的对象 |
keys | string [] | (k : string , v : any ) => boolean | 需要排除的属性名称 |
Returns
K
Defined in
packages/base/src/data.ts:75
pick
▸ pick<T
, K
>(target
, keys
): K
对象提取属性
Type parameters
Name | Type |
---|---|
T | extends Record <string , any > |
K | extends Record <string , any > |
Parameters
Name | Type |
---|---|
target | T |
keys | string [] | (k : string , v : any ) => boolean |
Returns
K
Defined in
packages/base/src/data.ts:103
random
▸ random(min
, max
): number
生成一个随机数
Parameters
Name | Type |
---|---|
min | number |
max | number |
Returns
number
Defined in
packages/base/src/util.ts:38
timestamp
▸ timestamp(): number
时间戳
Returns
number
Defined in
packages/base/src/util.ts:30
toArray
▸ toArray<T
>(maybeArray?
): T
[]
转换数组
Type parameters
Name | Type |
---|---|
T | any |
Parameters
Name | Type |
---|---|
maybeArray? | T | T [] |
Returns
T
[]
Defined in
packages/base/src/data.ts:47
toFixed
▸ toFixed(value
, number?
, round
): number
保留小数点,默认2位
Parameters
Name | Type | Default value | Description |
---|---|---|---|
value | number | undefined | 数值 |
number | number | 2 | 小数位数 |
round | boolean | undefined | 是否四舍五入 |
Returns
number
Defined in
packages/base/src/numeral.ts:20
toRawType
▸ toRawType(value
): string
获取原生数据类型
Parameters
Name | Type |
---|---|
value | unknown |
Returns
string
Defined in
packages/base/src/util.ts:9
toTypeString
▸ toTypeString(value
): string
Parameters
Name | Type |
---|---|
value | unknown |
Returns
string
Defined in
packages/base/src/util.ts:1
trim
▸ trim(obj
): any
递归对象或数组清除文本类型值的两边空格
Parameters
Name | Type |
---|---|
obj | any |
Returns
any
Defined in
packages/base/src/data.ts:130
uid
▸ uid(): string
唯一id
Returns
string
Defined in
packages/base/src/util.ts:48
unAES
▸ unAES(content
, key
): string
对称解密
Parameters
Name | Type |
---|---|
content | string |
key | string |
Returns
string
Defined in
packages/base/src/crypto.ts:88
unBase64
▸ unBase64(content
): string
Base64解码
Parameters
Name | Type |
---|---|
content | string |
Returns
string
Defined in
packages/base/src/crypto.ts:43
unRSA
▸ unRSA(content
, key?
): string
| false
非对称解密
Parameters
Name | Type | Default value | Description |
---|---|---|---|
content | string | undefined | 内容 |
key | string | RSA_PRIVATE_KEY | 私匙 |
Returns
string
| false
Defined in
packages/base/src/crypto.ts:66
upperFirstCamelCase
▸ upperFirstCamelCase(name
): string
Parameters
Name | Type |
---|---|
name | string |
Returns
string
Defined in
packages/base/src/lodash.ts:32
uuid
▸ uuid(split?
): string
生成一个 UUID 或 GUID, 默认GUID
Parameters
Name | Type | Default value | Description |
---|---|---|---|
split | boolean | true | true为GUID,fasle为UUID |
Returns
string
Defined in
packages/base/src/util.ts:59
zipObject
▸ zipObject(obj
): Record
<string
, any
>
压缩对称,清除值为undefined或null的属性
Parameters
Name | Type |
---|---|
obj | Record <string , any > |
Returns
Record
<string
, any
>
Defined in
packages/base/src/data.ts:56