feat: 新增类型校验函数

This commit is contained in:
MTrun
2022-03-15 19:40:55 +08:00
parent 9aec36b201
commit 0fdbeb1e7a
2 changed files with 25 additions and 1 deletions
+2 -1
View File
@@ -4,4 +4,5 @@ export * from '@/utils/router'
export * from '@/utils/storage'
export * from '@/utils/style'
export * from '@/utils/plugin'
export * from '@/utils/componets'
export * from '@/utils/componets'
export * from '@/utils/type'
+23
View 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)
}