mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-22 05:26:23 +08:00
feat: 新增类型校验函数
This commit is contained in:
parent
9aec36b201
commit
0fdbeb1e7a
@ -4,4 +4,5 @@ export * from '@/utils/router'
|
|||||||
export * from '@/utils/storage'
|
export * from '@/utils/storage'
|
||||||
export * from '@/utils/style'
|
export * from '@/utils/style'
|
||||||
export * from '@/utils/plugin'
|
export * from '@/utils/plugin'
|
||||||
export * from '@/utils/componets'
|
export * from '@/utils/componets'
|
||||||
|
export * from '@/utils/type'
|
23
src/utils/type.ts
Normal file
23
src/utils/type.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export function isString(p: any): p is string {
|
||||||
|
return typeof p === 'string'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isNumber(p: any): p is number {
|
||||||
|
return typeof p === 'number'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isBoolean(p: any): p is boolean {
|
||||||
|
return typeof p === 'boolean'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isUndefined(p: any): p is undefined {
|
||||||
|
return typeof p === 'undefined'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isNull(p: any): p is null {
|
||||||
|
return p === null
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isArray(p: any): p is [] {
|
||||||
|
return Array.isArray(p)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user