@ivujs/i-utils 1.1.17 → 2.0.0

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.
Files changed (204) hide show
  1. package/README.md +96 -30
  2. package/dist/cjs/ID-card/index.cjs +87 -0
  3. package/dist/cjs/array/index.cjs +470 -0
  4. package/dist/cjs/clipboard/index.cjs +128 -0
  5. package/dist/cjs/color/index.cjs +193 -0
  6. package/dist/cjs/constants/date.cjs +178 -0
  7. package/dist/cjs/constants/id-card.cjs +52 -0
  8. package/dist/cjs/constants/keycode.cjs +117 -0
  9. package/dist/cjs/constants/lang.cjs +13 -0
  10. package/dist/cjs/constants/math.cjs +13 -0
  11. package/dist/cjs/constants/regexp.cjs +53 -0
  12. package/dist/cjs/constants/sort.cjs +15 -0
  13. package/dist/cjs/cookie/index.cjs +70 -0
  14. package/dist/cjs/crypto/aes/aes.cjs +480 -0
  15. package/dist/cjs/crypto/aes/index.cjs +27 -0
  16. package/dist/cjs/crypto/base32/base32.cjs +357 -0
  17. package/dist/cjs/crypto/base32/index.cjs +41 -0
  18. package/dist/cjs/crypto/base64/base64.cjs +348 -0
  19. package/dist/cjs/crypto/base64/index.cjs +59 -0
  20. package/dist/cjs/crypto/des/des.cjs +257 -0
  21. package/dist/cjs/crypto/des/index.cjs +28 -0
  22. package/dist/cjs/crypto/md5/index.cjs +24 -0
  23. package/dist/cjs/crypto/md5/md5.cjs +897 -0
  24. package/dist/cjs/crypto/sha/sha1/index.cjs +24 -0
  25. package/dist/cjs/crypto/sha/sha1/sha1.cjs +529 -0
  26. package/dist/cjs/crypto/sha/sha256/index.cjs +43 -0
  27. package/dist/cjs/crypto/sha/sha256/sha256.cjs +595 -0
  28. package/dist/cjs/crypto/sha/sha3/index.cjs +41 -0
  29. package/dist/cjs/crypto/sha/sha3/sha3.cjs +624 -0
  30. package/dist/cjs/crypto/sha/sha512/index.cjs +81 -0
  31. package/dist/cjs/crypto/sha/sha512/sha512.cjs +950 -0
  32. package/dist/cjs/crypto/sm/lib/asn1.cjs +149 -0
  33. package/dist/cjs/crypto/sm/lib/ec.cjs +315 -0
  34. package/dist/cjs/crypto/sm/lib/jsbn.cjs +1608 -0
  35. package/dist/cjs/crypto/sm/lib/sm3.cjs +158 -0
  36. package/dist/cjs/crypto/sm/lib/utils.cjs +170 -0
  37. package/dist/cjs/crypto/sm/sm2/index.cjs +112 -0
  38. package/dist/cjs/crypto/sm/sm2/sm2.cjs +231 -0
  39. package/dist/cjs/crypto/sm/sm3/index.cjs +15 -0
  40. package/dist/cjs/crypto/sm/sm3/sm3.cjs +93 -0
  41. package/dist/cjs/crypto/sm/sm4/index.cjs +27 -0
  42. package/dist/cjs/crypto/sm/sm4/sm4.cjs +327 -0
  43. package/dist/cjs/crypto/tea/index.cjs +25 -0
  44. package/dist/cjs/crypto/tea/tea.cjs +187 -0
  45. package/dist/cjs/date/index.cjs +1266 -0
  46. package/dist/cjs/desensitized/index.cjs +75 -0
  47. package/dist/cjs/device/index.cjs +151 -0
  48. package/dist/cjs/dom/index.cjs +129 -0
  49. package/dist/cjs/file/index.cjs +333 -0
  50. package/dist/cjs/function/index.cjs +69 -0
  51. package/dist/cjs/index.cjs +402 -7
  52. package/dist/cjs/keycode/index.cjs +33 -0
  53. package/dist/cjs/math/index.cjs +278 -0
  54. package/dist/cjs/number/index.cjs +31 -0
  55. package/dist/cjs/object/index.cjs +272 -0
  56. package/dist/cjs/pagination/index.cjs +131 -0
  57. package/dist/cjs/random/index.cjs +24 -0
  58. package/dist/cjs/regexp/index.cjs +100 -0
  59. package/dist/cjs/storage/index.cjs +11 -0
  60. package/dist/cjs/storage/localStorage.cjs +37 -0
  61. package/dist/cjs/storage/sessionStorage.cjs +37 -0
  62. package/dist/cjs/string/index.cjs +358 -0
  63. package/dist/cjs/url/index.cjs +258 -0
  64. package/dist/cjs/validate/index.cjs +468 -0
  65. package/dist/cjs/weapp/index.cjs +142 -0
  66. package/dist/es/ID-card/index.d.ts +31 -0
  67. package/dist/es/ID-card/index.mjs +81 -0
  68. package/dist/es/array/index.d.ts +203 -0
  69. package/dist/es/array/index.mjs +441 -0
  70. package/dist/es/clipboard/index.d.ts +29 -0
  71. package/dist/es/clipboard/index.mjs +122 -0
  72. package/dist/es/color/index.d.ts +52 -0
  73. package/dist/es/color/index.mjs +183 -0
  74. package/dist/es/constants/date.d.ts +174 -0
  75. package/dist/es/constants/date.mjs +176 -0
  76. package/dist/es/constants/id-card.d.ts +43 -0
  77. package/dist/es/constants/id-card.mjs +50 -0
  78. package/dist/es/constants/index.d.ts +7 -0
  79. package/dist/es/constants/keycode.d.ts +103 -0
  80. package/dist/es/constants/keycode.mjs +115 -0
  81. package/dist/es/constants/lang.d.ts +4 -0
  82. package/dist/es/constants/lang.mjs +11 -0
  83. package/dist/es/constants/math.d.ts +4 -0
  84. package/dist/es/constants/math.mjs +11 -0
  85. package/dist/es/constants/regexp.d.ts +24 -0
  86. package/dist/es/constants/regexp.mjs +51 -0
  87. package/dist/es/constants/sort.d.ts +5 -0
  88. package/dist/es/constants/sort.mjs +13 -0
  89. package/dist/es/cookie/index.d.ts +29 -0
  90. package/dist/es/cookie/index.mjs +64 -0
  91. package/dist/es/crypto/aes/aes.d.ts +156 -0
  92. package/dist/es/crypto/aes/aes.mjs +478 -0
  93. package/dist/es/crypto/aes/index.d.ts +16 -0
  94. package/dist/es/crypto/aes/index.mjs +24 -0
  95. package/dist/es/crypto/base32/base32.d.ts +3 -0
  96. package/dist/es/crypto/base32/base32.mjs +353 -0
  97. package/dist/es/crypto/base32/index.d.ts +24 -0
  98. package/dist/es/crypto/base32/index.mjs +36 -0
  99. package/dist/es/crypto/base64/base64.d.ts +5 -0
  100. package/dist/es/crypto/base64/base64.mjs +342 -0
  101. package/dist/es/crypto/base64/index.d.ts +36 -0
  102. package/dist/es/crypto/base64/index.mjs +52 -0
  103. package/dist/es/crypto/des/des.d.ts +52 -0
  104. package/dist/es/crypto/des/des.mjs +255 -0
  105. package/dist/es/crypto/des/index.d.ts +14 -0
  106. package/dist/es/crypto/des/index.mjs +25 -0
  107. package/dist/es/crypto/index.d.ts +8 -0
  108. package/dist/es/crypto/md5/index.d.ts +13 -0
  109. package/dist/es/crypto/md5/index.mjs +21 -0
  110. package/dist/es/crypto/md5/md5.d.ts +144 -0
  111. package/dist/es/crypto/md5/md5.mjs +894 -0
  112. package/dist/es/crypto/sha/index.d.ts +4 -0
  113. package/dist/es/crypto/sha/sha1/index.d.ts +13 -0
  114. package/dist/es/crypto/sha/sha1/index.mjs +21 -0
  115. package/dist/es/crypto/sha/sha1/sha1.d.ts +2 -0
  116. package/dist/es/crypto/sha/sha1/sha1.mjs +526 -0
  117. package/dist/es/crypto/sha/sha256/index.d.ts +26 -0
  118. package/dist/es/crypto/sha/sha256/index.mjs +38 -0
  119. package/dist/es/crypto/sha/sha256/sha256.d.ts +4 -0
  120. package/dist/es/crypto/sha/sha256/sha256.mjs +590 -0
  121. package/dist/es/crypto/sha/sha3/index.d.ts +24 -0
  122. package/dist/es/crypto/sha/sha3/index.mjs +36 -0
  123. package/dist/es/crypto/sha/sha3/sha3.d.ts +4 -0
  124. package/dist/es/crypto/sha/sha3/sha3.mjs +619 -0
  125. package/dist/es/crypto/sha/sha512/index.d.ts +52 -0
  126. package/dist/es/crypto/sha/sha512/index.mjs +72 -0
  127. package/dist/es/crypto/sha/sha512/sha512.d.ts +8 -0
  128. package/dist/es/crypto/sha/sha512/sha512.mjs +941 -0
  129. package/dist/es/crypto/sm/index.d.ts +3 -0
  130. package/dist/es/crypto/sm/lib/asn1.d.ts +12 -0
  131. package/dist/es/crypto/sm/lib/asn1.mjs +146 -0
  132. package/dist/es/crypto/sm/lib/ec.d.ts +126 -0
  133. package/dist/es/crypto/sm/lib/ec.mjs +312 -0
  134. package/dist/es/crypto/sm/lib/jsbn.d.ts +198 -0
  135. package/dist/es/crypto/sm/lib/jsbn.mjs +1605 -0
  136. package/dist/es/crypto/sm/lib/sm3.d.ts +5 -0
  137. package/dist/es/crypto/sm/lib/sm3.mjs +155 -0
  138. package/dist/es/crypto/sm/lib/utils.d.ts +53 -0
  139. package/dist/es/crypto/sm/lib/utils.mjs +158 -0
  140. package/dist/es/crypto/sm/sm2/index.d.ts +71 -0
  141. package/dist/es/crypto/sm/sm2/index.mjs +101 -0
  142. package/dist/es/crypto/sm/sm2/sm2.d.ts +34 -0
  143. package/dist/es/crypto/sm/sm2/sm2.mjs +220 -0
  144. package/dist/es/crypto/sm/sm3/index.d.ts +7 -0
  145. package/dist/es/crypto/sm/sm3/index.mjs +13 -0
  146. package/dist/es/crypto/sm/sm3/sm3.d.ts +1 -0
  147. package/dist/es/crypto/sm/sm3/sm3.mjs +91 -0
  148. package/dist/es/crypto/sm/sm4/index.d.ts +16 -0
  149. package/dist/es/crypto/sm/sm4/index.mjs +24 -0
  150. package/dist/es/crypto/sm/sm4/sm4.d.ts +2 -0
  151. package/dist/es/crypto/sm/sm4/sm4.mjs +324 -0
  152. package/dist/es/crypto/tea/index.d.ts +14 -0
  153. package/dist/es/crypto/tea/index.mjs +22 -0
  154. package/dist/es/crypto/tea/tea.d.ts +69 -0
  155. package/dist/es/crypto/tea/tea.mjs +185 -0
  156. package/dist/es/date/index.d.ts +547 -0
  157. package/dist/es/date/index.mjs +1179 -0
  158. package/dist/es/desensitized/index.d.ts +38 -0
  159. package/dist/es/desensitized/index.mjs +69 -0
  160. package/dist/es/device/index.d.ts +67 -0
  161. package/dist/es/device/index.mjs +137 -0
  162. package/dist/es/dom/index.d.ts +57 -0
  163. package/dist/es/dom/index.mjs +119 -0
  164. package/dist/es/file/index.d.ts +93 -0
  165. package/dist/es/file/index.mjs +317 -0
  166. package/dist/es/function/index.d.ts +23 -0
  167. package/dist/es/function/index.mjs +65 -0
  168. package/dist/es/index.d.ts +26 -1
  169. package/dist/es/index.mjs +57 -4
  170. package/dist/es/keycode/index.d.ts +12 -0
  171. package/dist/es/keycode/index.mjs +30 -0
  172. package/dist/es/math/index.d.ts +66 -0
  173. package/dist/es/math/index.mjs +268 -0
  174. package/dist/es/number/index.d.ts +14 -0
  175. package/dist/es/number/index.mjs +28 -0
  176. package/dist/es/object/index.d.ts +83 -0
  177. package/dist/es/object/index.mjs +259 -0
  178. package/dist/es/pagination/index.d.ts +34 -0
  179. package/dist/es/pagination/index.mjs +125 -0
  180. package/dist/es/random/index.d.ts +15 -0
  181. package/dist/es/random/index.mjs +21 -0
  182. package/dist/es/regexp/index.d.ts +63 -0
  183. package/dist/es/regexp/index.mjs +89 -0
  184. package/dist/es/storage/index.d.ts +7 -0
  185. package/dist/es/storage/index.mjs +9 -0
  186. package/dist/es/storage/localStorage.d.ts +21 -0
  187. package/dist/es/storage/localStorage.mjs +32 -0
  188. package/dist/es/storage/sessionStorage.d.ts +21 -0
  189. package/dist/es/storage/sessionStorage.mjs +32 -0
  190. package/dist/es/string/index.d.ts +121 -0
  191. package/dist/es/string/index.mjs +339 -0
  192. package/dist/es/url/index.d.ts +118 -0
  193. package/dist/es/url/index.mjs +240 -0
  194. package/dist/es/validate/index.d.ts +228 -0
  195. package/dist/es/validate/index.mjs +431 -0
  196. package/dist/es/weapp/index.d.ts +57 -0
  197. package/dist/es/weapp/index.mjs +131 -0
  198. package/dist/index.d.ts +2857 -17
  199. package/dist/lib/index.full.umd.js +14238 -31
  200. package/dist/lib/index.full.umd.min.js +64 -2
  201. package/dist/lib/index.full.umd.min.js.map +1 -1
  202. package/dist/resolver/auto-imports.cjs +337 -1
  203. package/dist/resolver/auto-imports.mjs +337 -1
  204. package/package.json +90 -91
@@ -0,0 +1,228 @@
1
+ /**
2
+ * 判断是整数
3
+ * @param {*} value 参数
4
+ * @returns {Boolean} result 返回结果
5
+ */
6
+ export function isInteger(value: any): boolean;
7
+ /**
8
+ * 判断是小数
9
+ * @param {*} value 参数
10
+ * @returns {Boolean} result 返回结果
11
+ */
12
+ export function isDecimal(value: any): boolean;
13
+ /**
14
+ * 判断类型是数字 Number
15
+ * @param {Number} value 参数
16
+ * @returns {Boolean} 返回结果
17
+ */
18
+ export function isNumber(value: number): boolean;
19
+ /**
20
+ * 判断类型是字符串 String
21
+ * @param {*} value 参数
22
+ * @returns {Boolean} 返回结果
23
+ */
24
+ export function isString(value: any): boolean;
25
+ /**
26
+ * 判断类型是数组 Array
27
+ * @param {*} value 参数
28
+ * @returns {Boolean} 返回结果
29
+ */
30
+ export function isArray(value: any): boolean;
31
+ /**
32
+ * 判断类型是对象 Object
33
+ * @param {*} value 参数
34
+ * @returns {Boolean} 返回结果
35
+ */
36
+ export function isObject(value: any): boolean;
37
+ /**
38
+ * 判断类型是布尔 Boolean
39
+ * @param {*} value 参数
40
+ * @returns {Boolean} 返回结果
41
+ */
42
+ export function isBoolean(value: any): boolean;
43
+ /**
44
+ * 判断类型是日期 Date
45
+ * @param {*} value 参数
46
+ * @returns {Boolean} 返回结果
47
+ */
48
+ export function isDate(value: any): boolean;
49
+ /**
50
+ * 判断类型是函数 Function
51
+ * @param {*} value 参数
52
+ * @returns {Boolean} 返回结果
53
+ */
54
+ export function isFunction(value: any): boolean;
55
+ /**
56
+ * 判断类型是函数字符串 FunctionString
57
+ * @description 支持普通函数,异步函数,箭头函数
58
+ * @param {*} value 参数
59
+ * @returns {Boolean} 返回结果
60
+ */
61
+ export function isFunctionString(value: any): boolean;
62
+ /**
63
+ * 判断类型是异步函数 AsyncFunction
64
+ * @param {*} value 参数
65
+ * @returns {Boolean} 返回结果
66
+ */
67
+ export function isAsyncFunction(value: any): boolean;
68
+ /**
69
+ * 判断类型是 Symbol
70
+ * @param {*} value 参数
71
+ * @returns {Boolean} 返回结果
72
+ */
73
+ export function isSymbol(value: any): boolean;
74
+ /**
75
+ * 判断类型是正则 RegExp
76
+ * @param {*} value 参数
77
+ * @returns {Boolean} 返回结果
78
+ */
79
+ export function isRegExp(value: any): boolean;
80
+ /**
81
+ * 判断类型是错误 Error
82
+ * @param {*} value 参数
83
+ * @returns {Boolean} 返回结果
84
+ */
85
+ export function isError(value: any): boolean;
86
+ /**
87
+ * 判断类型是 Promise
88
+ * @param {*} value 参数
89
+ * @returns {Boolean} 返回结果
90
+ */
91
+ export function isPromise(value: any): boolean;
92
+ /**
93
+ *判断类型是 Map
94
+ * @param {*} value 参数
95
+ * @returns {Boolean} 返回结果
96
+ */
97
+ export function isMap(value: any): boolean;
98
+ /**
99
+ * 判断类型是 WeakMap
100
+ * @param {*} value 参数
101
+ * @returns {Boolean} 返回结果
102
+ */
103
+ export function isWeakMap(value: any): boolean;
104
+ /**
105
+ * 判断类型是 Set
106
+ * @param {*} value 参数
107
+ * @returns {Boolean} 返回结果
108
+ */
109
+ export function isSet(value: any): boolean;
110
+ /**
111
+ * 判断类型是 WeakSet
112
+ * @param {*} value 参数
113
+ * @returns {Boolean} 返回结果
114
+ */
115
+ export function isWeakSet(value: any): boolean;
116
+ /**
117
+ * 判断类型是 BigInt
118
+ * @param {*} value 参数
119
+ * @returns {Boolean} 返回结果
120
+ */
121
+ export function isBigInt(value: any): boolean;
122
+ /**
123
+ * 判断类型是 Json
124
+ * @param {*} value 参数
125
+ * @returns {Boolean} 返回结果
126
+ */
127
+ export function isJson(value: any): boolean;
128
+ /**
129
+ * 判断值为真
130
+ * @param {*} value 校验的参数
131
+ * @returns {Boolean} 返回结果
132
+ */
133
+ export function isTrue(value: any): boolean;
134
+ /**
135
+ * 判断值为假
136
+ * @param {*} value 校验的参数
137
+ * @returns {Boolean} 返回结果
138
+ */
139
+ export function isFalse(value: any): boolean;
140
+ /**
141
+ * 判断非数字
142
+ * @param {*} value 参数
143
+ * @returns {Boolean} 返回结果
144
+ */
145
+ export function isNaN(value: any): boolean;
146
+ /**
147
+ * 判断是数字
148
+ * @description 等同于isNumber()
149
+ * @param {*} value 参数
150
+ * @returns {Boolean} 返回结果
151
+ */
152
+ export function isNotNaN(value: any): boolean;
153
+ /**
154
+ * 判断对象为空
155
+ * @description 判断值是否为空,如果对象初始化了值则不为空
156
+ * @param {*} value 校验的参数
157
+ * @returns {Boolean} 返回结果
158
+ */
159
+ export function isNull(value: any): boolean;
160
+ /**
161
+ * 判断对象不为空
162
+ * @description 判断值是否为空,如果对象初始化了值则不为空
163
+ * @param {*} value 校验的参数
164
+ * @returns {Boolean} 返回结果
165
+ */
166
+ export function isNotNull(value: any): boolean;
167
+ /**
168
+ * 判断值为空
169
+ * @description 判断是否是有意义不为空的值,如果值是{},[]空的数据则为空
170
+ * @param {*} value 校验的参数
171
+ * @returns {Boolean} 返回结果
172
+ */
173
+ export function isEmpty(value: any): boolean;
174
+ /**
175
+ * 判断值不为空
176
+ * @description 判断是否是有意义不为空的值,如果值是{},[]空的数据则为空
177
+ * @param {*} value 校验的参数
178
+ * @returns {Boolean} 返回结果
179
+ */
180
+ export function isNotEmpty(value: any): boolean;
181
+ /**
182
+ * 判断值是空白的
183
+ * @description 同时会校验空值,空对象,以及空白符号
184
+ * @param {*} value 校验的参数
185
+ * @returns {Boolean} 返回结果
186
+ */
187
+ export function isBlank(value: any): boolean;
188
+ /**
189
+ * 判断值不是空白的
190
+ * @description 同时会校验空值,空对象,以及空白符号
191
+ * @param {*} value 校验的参数
192
+ * @returns {Boolean} 返回结果
193
+ */
194
+ export function isNotBlank(value: any): boolean;
195
+ /**
196
+ * 判断值是undefined
197
+ * @param {*} value 校验的参数
198
+ * @returns {Boolean} 返回结果
199
+ */
200
+ export function isUndefined(value: any): boolean;
201
+ /**
202
+ * 判断值不是undefined
203
+ * @param {*} value 校验的参数
204
+ * @returns {Boolean} 返回结果
205
+ */
206
+ export function isNotUndefined(value: any): boolean;
207
+ /**
208
+ * 判断两个值是否相等
209
+ * @param {String|Number} value1 参数1
210
+ * @param {String|Number} value2 参数2
211
+ * @returns {Boolean} 返回结果
212
+ */
213
+ export function equals(value1: string | number, value2: string | number): boolean;
214
+ /**
215
+ * 判断两个值是否相等(忽略大小写)
216
+ * @param {String|Number} value1 参数1
217
+ * @param {String|Number} value2 参数2
218
+ * @returns {Boolean} 返回结果
219
+ */
220
+ export function equalsIgnoreCase(value1: string | number, value2: string | number): boolean;
221
+ /**
222
+ * 深度对比数据
223
+ * @description 可以对比任意数据,对象,数组,日期等也可深度对比,对象不区分先后顺序
224
+ * @param {*} x 数据1
225
+ * @param {*} y 数据2
226
+ * @returns {Boolean} 返回结果
227
+ */
228
+ export function deepCompare(x: any, y: any, ...args: any[]): boolean;
@@ -0,0 +1,431 @@
1
+ /**
2
+ * 判断是整数
3
+ * @param {*} value 参数
4
+ * @returns {Boolean} result 返回结果
5
+ */
6
+ function isInteger(value) {
7
+ return Number.isInteger(value);
8
+ }
9
+ /**
10
+ * 判断是小数
11
+ * @param {*} value 参数
12
+ * @returns {Boolean} result 返回结果
13
+ */
14
+ function isDecimal(value) {
15
+ return /^\d+\.\d+$/.test(value);
16
+ }
17
+ /**
18
+ * 判断类型是数字 Number
19
+ * @param {Number} value 参数
20
+ * @returns {Boolean} 返回结果
21
+ */
22
+ function isNumber(value) {
23
+ return Object.prototype.toString.call(value).slice(8, -1) === "Number";
24
+ }
25
+ /**
26
+ * 判断类型是字符串 String
27
+ * @param {*} value 参数
28
+ * @returns {Boolean} 返回结果
29
+ */
30
+ function isString(value) {
31
+ return Object.prototype.toString.call(value).slice(8, -1) === "String";
32
+ }
33
+ /**
34
+ * 判断类型是数组 Array
35
+ * @param {*} value 参数
36
+ * @returns {Boolean} 返回结果
37
+ */
38
+ function isArray(value) {
39
+ return Object.prototype.toString.call(value).slice(8, -1) === "Array";
40
+ }
41
+ /**
42
+ * 判断类型是对象 Object
43
+ * @param {*} value 参数
44
+ * @returns {Boolean} 返回结果
45
+ */
46
+ function isObject(value) {
47
+ return Object.prototype.toString.call(value).slice(8, -1) === "Object";
48
+ }
49
+ /**
50
+ * 判断类型是布尔 Boolean
51
+ * @param {*} value 参数
52
+ * @returns {Boolean} 返回结果
53
+ */
54
+ function isBoolean(value) {
55
+ return Object.prototype.toString.call(value).slice(8, -1) === "Boolean";
56
+ }
57
+ /**
58
+ * 判断类型是日期 Date
59
+ * @param {*} value 参数
60
+ * @returns {Boolean} 返回结果
61
+ */
62
+ function isDate(value) {
63
+ return Object.prototype.toString.call(value).slice(8, -1) === "Date";
64
+ }
65
+ /**
66
+ * 判断类型是函数 Function
67
+ * @param {*} value 参数
68
+ * @returns {Boolean} 返回结果
69
+ */
70
+ function isFunction(value) {
71
+ return Object.prototype.toString.call(value).slice(8, -1) === "Function";
72
+ }
73
+ /**
74
+ * 判断类型是函数字符串 FunctionString
75
+ * @description 支持普通函数,异步函数,箭头函数
76
+ * @param {*} value 参数
77
+ * @returns {Boolean} 返回结果
78
+ */
79
+ function isFunctionString(value) {
80
+ if (value) {
81
+ try {
82
+ let fn = new Function(`return ${value}`)();
83
+ return typeof fn === "function";
84
+ }
85
+ catch (e) {
86
+ // 如果发生错误,比如语法错误,那么这不是一个有效的函数
87
+ return false;
88
+ }
89
+ }
90
+ else {
91
+ return false;
92
+ }
93
+ }
94
+ /**
95
+ * 判断类型是异步函数 AsyncFunction
96
+ * @param {*} value 参数
97
+ * @returns {Boolean} 返回结果
98
+ */
99
+ function isAsyncFunction(value) {
100
+ return Object.prototype.toString.call(value).slice(8, -1) === "AsyncFunction";
101
+ }
102
+ /**
103
+ * 判断类型是 Symbol
104
+ * @param {*} value 参数
105
+ * @returns {Boolean} 返回结果
106
+ */
107
+ function isSymbol(value) {
108
+ return Object.prototype.toString.call(value).slice(8, -1) === "Symbol";
109
+ }
110
+ /**
111
+ * 判断类型是正则 RegExp
112
+ * @param {*} value 参数
113
+ * @returns {Boolean} 返回结果
114
+ */
115
+ function isRegExp(value) {
116
+ return Object.prototype.toString.call(value).slice(8, -1) === "RegExp";
117
+ }
118
+ /**
119
+ * 判断类型是错误 Error
120
+ * @param {*} value 参数
121
+ * @returns {Boolean} 返回结果
122
+ */
123
+ function isError(value) {
124
+ return Object.prototype.toString.call(value).slice(8, -1) === "Error";
125
+ }
126
+ /**
127
+ * 判断类型是 Promise
128
+ * @param {*} value 参数
129
+ * @returns {Boolean} 返回结果
130
+ */
131
+ function isPromise(value) {
132
+ return Object.prototype.toString.call(value).slice(8, -1) === "Promise";
133
+ }
134
+ /**
135
+ *判断类型是 Map
136
+ * @param {*} value 参数
137
+ * @returns {Boolean} 返回结果
138
+ */
139
+ function isMap(value) {
140
+ return Object.prototype.toString.call(value).slice(8, -1) === "Map";
141
+ }
142
+ /**
143
+ * 判断类型是 WeakMap
144
+ * @param {*} value 参数
145
+ * @returns {Boolean} 返回结果
146
+ */
147
+ function isWeakMap(value) {
148
+ return Object.prototype.toString.call(value).slice(8, -1) === "WeakMap";
149
+ }
150
+ /**
151
+ * 判断类型是 Set
152
+ * @param {*} value 参数
153
+ * @returns {Boolean} 返回结果
154
+ */
155
+ function isSet(value) {
156
+ return Object.prototype.toString.call(value).slice(8, -1) === "Set";
157
+ }
158
+ /**
159
+ * 判断类型是 WeakSet
160
+ * @param {*} value 参数
161
+ * @returns {Boolean} 返回结果
162
+ */
163
+ function isWeakSet(value) {
164
+ return Object.prototype.toString.call(value).slice(8, -1) === "WeakSet";
165
+ }
166
+ /**
167
+ * 判断类型是 BigInt
168
+ * @param {*} value 参数
169
+ * @returns {Boolean} 返回结果
170
+ */
171
+ function isBigInt(value) {
172
+ return Object.prototype.toString.call(value).slice(8, -1) === "BigInt";
173
+ }
174
+ /**
175
+ * 判断类型是 Json
176
+ * @param {*} value 参数
177
+ * @returns {Boolean} 返回结果
178
+ */
179
+ function isJson(value) {
180
+ try {
181
+ JSON.parse(value);
182
+ return true;
183
+ }
184
+ catch (error) {
185
+ return false;
186
+ }
187
+ }
188
+ /* 数据值校验 */
189
+ /**
190
+ * 判断值为真
191
+ * @param {*} value 校验的参数
192
+ * @returns {Boolean} 返回结果
193
+ */
194
+ function isTrue(value) {
195
+ return !isFalse(value);
196
+ }
197
+ /**
198
+ * 判断值为假
199
+ * @param {*} value 校验的参数
200
+ * @returns {Boolean} 返回结果
201
+ */
202
+ function isFalse(value) {
203
+ return (value === undefined ||
204
+ value === null ||
205
+ value === "undefined" ||
206
+ value === "null" ||
207
+ value === 0 ||
208
+ value === false ||
209
+ isNaN(value));
210
+ }
211
+ /**
212
+ * 判断非数字
213
+ * @param {*} value 参数
214
+ * @returns {Boolean} 返回结果
215
+ */
216
+ function isNaN(value) {
217
+ // window的isNaN函数是有缺陷的,空数组/数组有一个元素,null,空字符串 都会被认为是数字
218
+ return window.isNaN(value) || isArray(value) || value == null || value === "";
219
+ }
220
+ /**
221
+ * 判断是数字
222
+ * @description 等同于isNumber()
223
+ * @param {*} value 参数
224
+ * @returns {Boolean} 返回结果
225
+ */
226
+ function isNotNaN(value) {
227
+ return !isNaN(value);
228
+ }
229
+ /**
230
+ * 判断对象为空
231
+ * @description 判断值是否为空,如果对象初始化了值则不为空
232
+ * @param {*} value 校验的参数
233
+ * @returns {Boolean} 返回结果
234
+ */
235
+ function isNull(value) {
236
+ return value === undefined || value === null || value === "";
237
+ }
238
+ /**
239
+ * 判断对象不为空
240
+ * @description 判断值是否为空,如果对象初始化了值则不为空
241
+ * @param {*} value 校验的参数
242
+ * @returns {Boolean} 返回结果
243
+ */
244
+ function isNotNull(value) {
245
+ return !isNull(value);
246
+ }
247
+ /**
248
+ * 判断值为空
249
+ * @description 判断是否是有意义不为空的值,如果值是{},[]空的数据则为空
250
+ * @param {*} value 校验的参数
251
+ * @returns {Boolean} 返回结果
252
+ */
253
+ function isEmpty(value) {
254
+ if (isNull(value))
255
+ return true;
256
+ if (typeof value === "string" || Array.isArray(value)) {
257
+ return value.length === 0;
258
+ }
259
+ if (typeof value === "object") {
260
+ if (value instanceof Map || value instanceof Set) {
261
+ return value.size === 0;
262
+ }
263
+ if (value instanceof Date || value instanceof RegExp || value instanceof Error) {
264
+ return false;
265
+ }
266
+ return Object.keys(value).length === 0;
267
+ }
268
+ return false;
269
+ }
270
+ /**
271
+ * 判断值不为空
272
+ * @description 判断是否是有意义不为空的值,如果值是{},[]空的数据则为空
273
+ * @param {*} value 校验的参数
274
+ * @returns {Boolean} 返回结果
275
+ */
276
+ function isNotEmpty(value) {
277
+ return !isEmpty(value);
278
+ }
279
+ /**
280
+ * 判断值是空白的
281
+ * @description 同时会校验空值,空对象,以及空白符号
282
+ * @param {*} value 校验的参数
283
+ * @returns {Boolean} 返回结果
284
+ */
285
+ function isBlank(value) {
286
+ return isEmpty(value) || /^\s*$/.test(value);
287
+ }
288
+ /**
289
+ * 判断值不是空白的
290
+ * @description 同时会校验空值,空对象,以及空白符号
291
+ * @param {*} value 校验的参数
292
+ * @returns {Boolean} 返回结果
293
+ */
294
+ function isNotBlank(value) {
295
+ return !isBlank(value);
296
+ }
297
+ /**
298
+ * 判断值是undefined
299
+ * @param {*} value 校验的参数
300
+ * @returns {Boolean} 返回结果
301
+ */
302
+ function isUndefined(value) {
303
+ return value === undefined;
304
+ }
305
+ /**
306
+ * 判断值不是undefined
307
+ * @param {*} value 校验的参数
308
+ * @returns {Boolean} 返回结果
309
+ */
310
+ function isNotUndefined(value) {
311
+ return !isUndefined(value);
312
+ }
313
+ /* 数据比较 */
314
+ /**
315
+ * 判断两个值是否相等
316
+ * @param {String|Number} value1 参数1
317
+ * @param {String|Number} value2 参数2
318
+ * @returns {Boolean} 返回结果
319
+ */
320
+ function equals(value1, value2) {
321
+ return Object.is(value1, value2);
322
+ }
323
+ /**
324
+ * 判断两个值是否相等(忽略大小写)
325
+ * @param {String|Number} value1 参数1
326
+ * @param {String|Number} value2 参数2
327
+ * @returns {Boolean} 返回结果
328
+ */
329
+ function equalsIgnoreCase(value1, value2) {
330
+ return Object.is(value1.toLowerCase(), value2.toLowerCase());
331
+ }
332
+ /**
333
+ * 深度对比数据
334
+ * @description 可以对比任意数据,对象,数组,日期等也可深度对比,对象不区分先后顺序
335
+ * @param {*} x 数据1
336
+ * @param {*} y 数据2
337
+ * @returns {Boolean} 返回结果
338
+ */
339
+ function deepCompare(x, y) {
340
+ let i, l, leftChain, rightChain;
341
+ function compare2Objects(x, y) {
342
+ let p;
343
+ // remember that NaN === NaN returns false
344
+ // and isNaN(undefined) returns true
345
+ if (isNaN(x) && isNaN(y) && typeof x === "number" && typeof y === "number") {
346
+ return true;
347
+ }
348
+ // Compare primitives and functions.
349
+ // Check if both arguments link to the same object.
350
+ // Especially useful on the step where we compare prototypes
351
+ if (x === y) {
352
+ return true;
353
+ }
354
+ // Works in case when functions are created in constructor.
355
+ // Comparing dates is a common scenario. Another built-ins?
356
+ // We can even handle functions passed across iframes
357
+ if ((typeof x === "function" && typeof y === "function") ||
358
+ (x instanceof Date && y instanceof Date) ||
359
+ (x instanceof RegExp && y instanceof RegExp) ||
360
+ (x instanceof String && y instanceof String) ||
361
+ (x instanceof Number && y instanceof Number)) {
362
+ return x.toString() === y.toString();
363
+ }
364
+ // At last checking prototypes as good as we can
365
+ if (!(x instanceof Object && y instanceof Object)) {
366
+ return false;
367
+ }
368
+ if (x.isPrototypeOf(y) || y.isPrototypeOf(x)) {
369
+ return false;
370
+ }
371
+ if (x.constructor !== y.constructor) {
372
+ return false;
373
+ }
374
+ if (x.prototype !== y.prototype) {
375
+ return false;
376
+ }
377
+ // Check for infinitive linking loops
378
+ if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1) {
379
+ return false;
380
+ }
381
+ // Quick checking of one object being a subset of another.
382
+ for (p in y) {
383
+ if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
384
+ return false;
385
+ }
386
+ else if (typeof y[p] !== typeof x[p]) {
387
+ return false;
388
+ }
389
+ }
390
+ for (p in x) {
391
+ if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
392
+ return false;
393
+ }
394
+ else if (typeof y[p] !== typeof x[p]) {
395
+ return false;
396
+ }
397
+ switch (typeof x[p]) {
398
+ case "object":
399
+ case "function":
400
+ leftChain.push(x);
401
+ rightChain.push(y);
402
+ if (!compare2Objects(x[p], y[p])) {
403
+ return false;
404
+ }
405
+ leftChain.pop();
406
+ rightChain.pop();
407
+ break;
408
+ default:
409
+ if (x[p] !== y[p]) {
410
+ return false;
411
+ }
412
+ break;
413
+ }
414
+ }
415
+ return true;
416
+ }
417
+ if (arguments.length < 1) {
418
+ return true; // Die silently? Don't know how to handle such case, please help...
419
+ // throw "Need two or more arguments to compare";
420
+ }
421
+ for (i = 1, l = arguments.length; i < l; i++) {
422
+ leftChain = [];
423
+ rightChain = [];
424
+ if (!compare2Objects(arguments[0], arguments[i])) {
425
+ return false;
426
+ }
427
+ }
428
+ return true;
429
+ }
430
+
431
+ export { deepCompare, equals, equalsIgnoreCase, isArray, isAsyncFunction, isBigInt, isBlank, isBoolean, isDate, isDecimal, isEmpty, isError, isFalse, isFunction, isFunctionString, isInteger, isJson, isMap, isNaN, isNotBlank, isNotEmpty, isNotNaN, isNotNull, isNotUndefined, isNull, isNumber, isObject, isPromise, isRegExp, isSet, isString, isSymbol, isTrue, isUndefined, isWeakMap, isWeakSet };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * 设置缓存
3
+ * @param {String} key key值
4
+ * @param {*} data data数据
5
+ */
6
+ export function setStorageSync(key: string, data: any): void;
7
+ /**
8
+ * 获得缓存数据
9
+ * @param {String} key key值
10
+ * @returns {*} 返回获取的值
11
+ */
12
+ export function getStorageSync(key: string): any;
13
+ /**
14
+ * 获得缓存信息
15
+ * @returns {Object} 返回缓存信息
16
+ */
17
+ export function getStorageInfoSync(): Object;
18
+ /**
19
+ * 删除缓存数据
20
+ * @param {String} key key值
21
+ */
22
+ export function removeStorageSync(key: string): void;
23
+ /**
24
+ * 清空所有缓存数据
25
+ */
26
+ export function clearStorageSync(): void;
27
+ /**
28
+ * 设置缓存
29
+ * @param {String} key key值
30
+ * @param {*} data data数据
31
+ * @param {Boolean} encrypt 是否开启加密存储
32
+ * @returns {Promise} 返回Promise
33
+ */
34
+ export function setStorage({ key, data, encrypt }: string): Promise<any>;
35
+ /**
36
+ * 获得缓存数据
37
+ * @param {String} key key值
38
+ * @param {Boolean} encrypt 是否开启加密存储
39
+ * @returns {Promise} 返回Promise
40
+ */
41
+ export function getStorage({ key, encrypt }: string): Promise<any>;
42
+ /**
43
+ * 获得缓存信息
44
+ * @returns {Object} 返回Promise
45
+ */
46
+ export function getStorageInfo(): Object;
47
+ /**
48
+ * 删除缓存数据
49
+ * @param {String} key key值
50
+ * @returns {Promise} 返回Promise
51
+ */
52
+ export function removeStorage({ key }: string): Promise<any>;
53
+ /**
54
+ * 清空所有缓存数据
55
+ * @returns {Promise} 返回Promise
56
+ */
57
+ export function clearStorage(): Promise<any>;