@creejs/commons-lang 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,91 @@
1
+ /**
2
+ * if value is not a Number, throw error
3
+ * @param {*} value
4
+ * @returns {void}
5
+ * @throws {Error}
6
+ */
7
+ export function assertNumber(value: any): void;
8
+ /**
9
+ * if value is not a string, throw error
10
+ * @param {*} value
11
+ * @returns {void}
12
+ * @throws {Error}
13
+ */
14
+ export function assertBoolean(value: any): void;
15
+ /**
16
+ * if value is not a Object, throw error
17
+ * @param {*} value
18
+ * @returns {void}
19
+ * @throws {Error}
20
+ */
21
+ export function assertObject(value: any): void;
22
+ /**
23
+ * if value is not a PlainObject, throw error
24
+ * @param {*} value
25
+ * @returns {void}
26
+ * @throws {Error}
27
+ */
28
+ export function assertPlainObject(value: any): void;
29
+ /**
30
+ * if value is not a Symbol, throw error
31
+ * @param {*} value
32
+ * @returns {void}
33
+ * @throws {Error}
34
+ */
35
+ export function assertSymbol(value: any): void;
36
+ /**
37
+ * if value is not a Function, throw error
38
+ * @param {*} value
39
+ * @returns {void}
40
+ * @throws {Error}
41
+ */
42
+ export function assertFunction(value: any): void;
43
+ /**
44
+ * if value is not a Class instance, throw error
45
+ * @param {*} value
46
+ * @returns {void}
47
+ * @throws {Error}
48
+ */
49
+ export function assertInstance(value: any): void;
50
+ /**
51
+ * if value is not a string, throw error
52
+ * @param {*} value
53
+ * @returns {void}
54
+ * @throws {Error}
55
+ */
56
+ export function assertPromise(value: any): void;
57
+ /**
58
+ * if value is not a Null or Undefined, throw error
59
+ * @param {*} value
60
+ * @returns {void}
61
+ * @throws {Error}
62
+ */
63
+ export function assertNil(value: any): void;
64
+ /**
65
+ * if value is not a Null, throw error
66
+ * @param {*} value
67
+ * @returns {void}
68
+ * @throws {Error}
69
+ */
70
+ export function assertNull(value: any): void;
71
+ /**
72
+ * if value is not a Undefined, throw error
73
+ * @param {*} value
74
+ * @returns {void}
75
+ * @throws {Error}
76
+ */
77
+ export function assertUndefined(value: any): void;
78
+ /**
79
+ * if value is not a string, throw error
80
+ * @param {*} value
81
+ * @returns {void}
82
+ * @throws {Error}
83
+ */
84
+ export function assertString(value: any): void;
85
+ /**
86
+ * if value is not Array, throw error
87
+ * @param {*} value
88
+ * @returns {void}
89
+ * @throws {Error}
90
+ */
91
+ export function assertArray(value: any): void;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * if value is not a string, throw error
3
+ * @param {*} value
4
+ * @returns {void}
5
+ * @throws {Error}
6
+ */
7
+ export function assertString(value: any): void;
8
+ /**
9
+ * if value is not a Number, throw error
10
+ * @param {*} value
11
+ * @returns {void}
12
+ * @throws {Error}
13
+ */
14
+ export function assertNumber(value: any): void;
15
+ /**
16
+ * if value is not a string, throw error
17
+ * @param {*} value
18
+ * @returns {void}
19
+ * @throws {Error}
20
+ */
21
+ export function assertBoolean(value: any): void;
22
+ /**
23
+ * if value is not a Object, throw error
24
+ * @param {*} value
25
+ * @returns {void}
26
+ * @throws {Error}
27
+ */
28
+ export function assertObject(value: any): void;
29
+ /**
30
+ * if value is not a PlainObject, throw error
31
+ * @param {*} value
32
+ * @returns {void}
33
+ * @throws {Error}
34
+ */
35
+ export function assertPlainObject(value: any): void;
36
+ /**
37
+ * if value is not a Symbol, throw error
38
+ * @param {*} value
39
+ * @returns {void}
40
+ * @throws {Error}
41
+ */
42
+ export function assertSymbol(value: any): void;
43
+ /**
44
+ * if value is not a Function, throw error
45
+ * @param {*} value
46
+ * @returns {void}
47
+ * @throws {Error}
48
+ */
49
+ export function assertFunction(value: any): void;
50
+ /**
51
+ * if value is not a Class instance, throw error
52
+ * @param {*} value
53
+ * @returns {void}
54
+ * @throws {Error}
55
+ */
56
+ export function assertInstance(value: any): void;
57
+ /**
58
+ * if value is not a string, throw error
59
+ * @param {*} value
60
+ * @returns {void}
61
+ * @throws {Error}
62
+ */
63
+ export function assertPromise(value: any): void;
64
+ /**
65
+ * if value is not a Null or Undefined, throw error
66
+ * @param {*} value
67
+ * @returns {void}
68
+ * @throws {Error}
69
+ */
70
+ export function assertNil(value: any): void;
71
+ /**
72
+ * if value is not a Null, throw error
73
+ * @param {*} value
74
+ * @returns {void}
75
+ * @throws {Error}
76
+ */
77
+ export function assertNull(value: any): void;
78
+ /**
79
+ * if value is not a Undefined, throw error
80
+ * @param {*} value
81
+ * @returns {void}
82
+ * @throws {Error}
83
+ */
84
+ export function assertUndefined(value: any): void;
@@ -0,0 +1,158 @@
1
+ /**
2
+ * @module TypeUtils
3
+ * @description Utility functions for type checking and validation.
4
+ */
5
+ /**
6
+ * Checks if the given value is an array.
7
+ * @param {*} value - The value to check.
8
+ * @returns {boolean} True if the value is an array, false otherwise.
9
+ */
10
+ export function isArray(value: any): boolean;
11
+ /**
12
+ * Checks if the given value is a boolean.
13
+ * @param {*} value - The value to check.
14
+ * @returns {boolean} True if the value is a boolean, false otherwise.
15
+ */
16
+ export function isBoolean(value: any): boolean;
17
+ /**
18
+ * Checks if the given value is a Buffer.
19
+ * @param {*} value - The value to check.
20
+ * @returns {boolean} True if the value is a Buffer, false otherwise.
21
+ */
22
+ export function isBuffer(value: any): boolean;
23
+ /**
24
+ * Checks if the given value is a function.
25
+ * @param {*} value - The value to check.
26
+ * @returns {boolean} True if the value is a function, false otherwise.
27
+ */
28
+ export function isFunction(value: any): boolean;
29
+ /**
30
+ * Checks if a value is a class instance (non-null and not a plain object).
31
+ * @param {*} value - The value to check.
32
+ * @returns {boolean} True if the value is a class instance, false otherwise.
33
+ */
34
+ export function isInstance(value: any): boolean;
35
+ /**
36
+ * Checks if a value is isIterable
37
+ * @param {*} value - The value to check.
38
+ * @returns {boolean} True if the value is isIterable, false otherwise.
39
+ */
40
+ export function isIterable(value: any): boolean;
41
+ /**
42
+ * Checks if the given value is a Date.
43
+ * @param {*} value - The value to check.
44
+ * @returns {boolean} True if the value is a Date, false otherwise.
45
+ */
46
+ export function isDate(value: any): boolean;
47
+ /**
48
+ * Checks if the given value is an instance of Error.
49
+ * @param {*} value - The value to check.
50
+ * @returns {boolean} True if the value is an Error, false otherwise.
51
+ */
52
+ export function isError(value: any): boolean;
53
+ /**
54
+ * Checks if a value is Map
55
+ * @param {*} value - The value to check.
56
+ * @returns {boolean} True if the value is Map, otherwise false.
57
+ */
58
+ export function isMap(value: any): boolean;
59
+ /**
60
+ * Checks if a value is WeakMap
61
+ * @param {*} value - The value to check.
62
+ * @returns {boolean} True if the value is WeakMap, otherwise false.
63
+ */
64
+ export function isWeakMap(value: any): boolean;
65
+ /**
66
+ * Checks if a value is a number.
67
+ * @param {*} value - The value to check.
68
+ * @returns {boolean} True if the value is a number, false otherwise.
69
+ */
70
+ export function isNumber(value: any): boolean;
71
+ /**
72
+ * Checks if a value is null or undefined.
73
+ * 1. value == null
74
+ * 2. return true, if value is null or undefined
75
+ * @param {*} value - The value to check.
76
+ * @returns {boolean} True if the value is null or undefined, otherwise false.
77
+ */
78
+ export function isNil(value: any): boolean;
79
+ /**
80
+ * Checks if a value is null or undefined.
81
+ * 1. same with isNil()
82
+ * @param {*} value - The value to check.
83
+ * @returns {boolean} True if the value is null or undefined, otherwise false.
84
+ */
85
+ export function isNullOrUndefined(value: any): boolean;
86
+ /**
87
+ * Checks if the given value is exactly null.
88
+ * @param {*} value - The value to check.
89
+ * @returns {boolean} True if the value is null, false otherwise.
90
+ */
91
+ export function isNull(value: any): boolean;
92
+ /**
93
+ * Checks if a value is exactly undefined.
94
+ * @param {*} value - The value to check.
95
+ * @returns {boolean} True if the value is undefined, false otherwise.
96
+ */
97
+ export function isUndefined(value: any): boolean;
98
+ /**
99
+ * Checks if a value is a plain object (created by the Object constructor).
100
+ * @param {*} value - The value to check.
101
+ * @returns {boolean} True if the value is a plain object, false otherwise.
102
+ */
103
+ export function isPlainObject(value: any): boolean;
104
+ /**
105
+ * Checks if a value is an object (and not null).
106
+ * @param {*} value - The value to check
107
+ * @returns {boolean} True if the value is an object (not null), false otherwise
108
+ */
109
+ export function isObject(value: any): boolean;
110
+ /**
111
+ * Checks if a value is a Promise.
112
+ * @param {*} value - The value to check.
113
+ * @returns {boolean} True if the value is a Promise, false otherwise.
114
+ */
115
+ export function isPromise(value: any): boolean;
116
+ /**
117
+ * Checks if a RegExp
118
+ * @param {*} value - The value to check.
119
+ * @returns {boolean} True if the value is RegExp, otherwise false.
120
+ */
121
+ export function isRegExp(value: any): boolean;
122
+ /**
123
+ * Checks if a Set
124
+ * @param {*} value - The value to check.
125
+ * @returns {boolean} True if the value is Set, otherwise false.
126
+ */
127
+ export function isSet(value: any): boolean;
128
+ /**
129
+ * Checks if a WeakSet
130
+ * @param {*} value - The value to check.
131
+ * @returns {boolean} True if the value is WeakSet, otherwise false.
132
+ */
133
+ export function isWeakSet(value: any): boolean;
134
+ /**
135
+ * Check if the value is a string
136
+ * @param {*} value
137
+ * @return {boolean}
138
+ */
139
+ export function isStream(value: any): boolean;
140
+ /**
141
+ * Check if the value is a string
142
+ * @param {*} value
143
+ * @return {boolean}
144
+ */
145
+ export function isString(value: any): boolean;
146
+ /**
147
+ * Checks if the given value is a Symbol.
148
+ * @param {*} value - The value to check.
149
+ * @returns {boolean} True if the value is a Symbol, false otherwise.
150
+ */
151
+ export function isSymbol(value: any): boolean;
152
+ /**
153
+ * check if value is primitive: string, number, boolean
154
+ * 1. null/undefined returns false
155
+ * @param {*} value
156
+ * @returns {boolean}
157
+ */
158
+ export function isPrimitive(value: any): boolean;