From 94672221e5083ad990a1106d34a19adab2f814cd Mon Sep 17 00:00:00 2001 From: MTrun <1262327911@qq.com> Date: Tue, 15 Mar 2022 19:40:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.ts | 3 ++- src/utils/type.ts | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/utils/type.ts diff --git a/src/utils/index.ts b/src/utils/index.ts index d6ced66f..dce187b9 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -4,4 +4,5 @@ export * from '@/utils/router' export * from '@/utils/storage' export * from '@/utils/style' export * from '@/utils/plugin' -export * from '@/utils/componets' \ No newline at end of file +export * from '@/utils/componets' +export * from '@/utils/type' \ No newline at end of file diff --git a/src/utils/type.ts b/src/utils/type.ts new file mode 100644 index 00000000..57a925d6 --- /dev/null +++ b/src/utils/type.ts @@ -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) +}