zhangxiao
2024-08-20 e47b788ff5f5c699c682999c95da17eb284ca21d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/** 检测对象类型 */
const typeHelper = {
    /**
     * 检测对象类型是否是Object
     *  @param {any} o 检测对象
     */
    isObject: (o: any): boolean => {
        if (Object.prototype.toString.call(o) === "[object Object]") {
            return true;
        }
        return false;
    },
    /**
     * 检测对象类型是否是Date
     *  @param {any} o 检测对象
     */
    isDate: (o: any): boolean => {
        if (Object.prototype.toString.call(o) === "[object Date]") {
            return true;
        }
        return false;
    },
 
    /**
     * 检测对象类型是否是String
     *  @param {any} o 检测对象
     */
    isString: (o: any): boolean => {
        if (Object.prototype.toString.call(o) === "[object String]") {
            return true;
        }
        return false;
    },
 
    /**
     * 检测对象类型是否是Array
     *  @param {any} o 检测对象
     */
    isArray: (o: any): boolean => {
        if (Object.prototype.toString.call(o) === "[object Array]") {
            return true;
        }
        return false;
    },
 
    /**
     * 检测对象类型是否是Number
     *  @param {any} o 检测对象
     */
    isNumber: (o: any): boolean => {
        if (Object.prototype.toString.call(o) === "[object Number]") {
            return true;
        }
        return false;
    },
 
    /**
     * 检测对象类型是否是Undefined
     *  @param {any} o 检测对象
     */
    isUndefined: (o: any): boolean => {
        if (Object.prototype.toString.call(o) === "[object Undefined]") {
            return true;
        }
        return false;
    },
 
    /**
     * 检测对象类型是否是Boolean
     *  @param {any} o 检测对象
     */
    isBoolean: (o: any): boolean => {
        if (Object.prototype.toString.call(o) === "[object Boolean]") {
            return true;
        }
        return false;
    },
 
    /**
     * 检测对象类型是否是Function
     *  @param {any} o 检测对象
     */
    isFunction: (o: any): boolean => {
        if (Object.prototype.toString.call(o) === "[object Function]") {
            return true;
        }
        return false;
    },
 
    /**
     * 检测对象类型是否是Null
     *  @param {any} o 检测对象
     */
    isNull: (o: any): boolean => {
        if (Object.prototype.toString.call(o) === "[object Null]") {
            return true;
        }
        return false;
    }
};
 
export default typeHelper;