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