ut2 1.20.1 → 1.21.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.
- package/README.md +1 -1
- package/dist/ut2.js +18 -8
- package/dist/ut2.js.map +1 -1
- package/dist/ut2.min.js +1 -1
- package/dist/ut2.min.js.map +1 -1
- package/es/equalArrayLike.js +2 -16
- package/es/index.js +1 -0
- package/es/internals/helpers.js +1 -1
- package/es/memoize.js +2 -2
- package/es/shallowEqual.js +26 -0
- package/lib/equalArrayLike.js +2 -16
- package/lib/index.js +2 -0
- package/lib/internals/helpers.js +1 -1
- package/lib/memoize.js +2 -2
- package/lib/shallowEqual.js +28 -0
- package/package.json +1 -1
- package/types/equalArrayLike.d.ts +4 -30
- package/types/index.d.ts +1 -0
- package/types/memoize.d.ts +1 -1
- package/types/shallowEqual.d.ts +39 -0
package/README.md
CHANGED
|
@@ -191,7 +191,6 @@ const debounced = debounce(() => {
|
|
|
191
191
|
- [constant](https://caijf.github.io/ut2/module-Util.html#.constant) - 返回自身的函数。
|
|
192
192
|
- [defaultTo](https://caijf.github.io/ut2/module-Util.html#.defaultTo) - 默认值。
|
|
193
193
|
- [eq](https://caijf.github.io/ut2/module-Util.html#.eq) - 等于。
|
|
194
|
-
- [equalArrayLike](https://caijf.github.io/ut2/module-Util.html#.equalArrayLike) - 比较类数组。
|
|
195
194
|
- [gt](https://caijf.github.io/ut2/module-Util.html#.gt) - 大于。
|
|
196
195
|
- [gte](https://caijf.github.io/ut2/module-Util.html#.gte) - 大于等于。
|
|
197
196
|
- [guard](https://caijf.github.io/ut2/module-Util.html#.guard) - 函数守卫。
|
|
@@ -204,6 +203,7 @@ const debounced = debounce(() => {
|
|
|
204
203
|
- [range](https://caijf.github.io/ut2/module-Util.html#.range) - 创建升序或降序的数字数组。
|
|
205
204
|
- [retry](https://caijf.github.io/ut2/module-Util.html#.retry) - 异步函数错误重试。
|
|
206
205
|
- [sleep](https://caijf.github.io/ut2/module-Util.html#.sleep) - 返回 `promise` 延迟。
|
|
206
|
+
- [shallowEqual](https://caijf.github.io/ut2/module-Util.html#.shallowEqual) - 浅比较。
|
|
207
207
|
- [toFinite](https://caijf.github.io/ut2/module-Util.html#.toFinite) - 转为有限数字。
|
|
208
208
|
- [toInteger](https://caijf.github.io/ut2/module-Util.html#.toInteger) - 转为整数。
|
|
209
209
|
- [toLength](https://caijf.github.io/ut2/module-Util.html#.toLength) - 转为数组长度整数。
|
package/dist/ut2.js
CHANGED
|
@@ -607,7 +607,7 @@
|
|
|
607
607
|
return value == null || value !== value ? defaultValue : value;
|
|
608
608
|
};
|
|
609
609
|
|
|
610
|
-
var VERSION = "1.
|
|
610
|
+
var VERSION = "1.21.0";
|
|
611
611
|
var isBrowser = typeof window !== stringUndefined && isObjectLike(window) && typeof document !== stringUndefined && isObjectLike(document) && window.document === document;
|
|
612
612
|
var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
|
|
613
613
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
@@ -899,17 +899,24 @@
|
|
|
899
899
|
return limited;
|
|
900
900
|
}
|
|
901
901
|
|
|
902
|
-
function
|
|
902
|
+
function shallowEqual(objA, objB, strictCheck) {
|
|
903
903
|
if (strictCheck === void 0) { strictCheck = true; }
|
|
904
|
-
if (eq(
|
|
904
|
+
if (eq(objA, objB, strictCheck)) {
|
|
905
905
|
return true;
|
|
906
|
-
|
|
906
|
+
}
|
|
907
|
+
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
907
908
|
return false;
|
|
908
|
-
|
|
909
|
+
}
|
|
910
|
+
var keysA = Object.keys(objA);
|
|
911
|
+
var keysB = Object.keys(objB);
|
|
912
|
+
if (keysA.length !== keysB.length) {
|
|
909
913
|
return false;
|
|
910
|
-
|
|
911
|
-
|
|
914
|
+
}
|
|
915
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
916
|
+
var key = keysA[i];
|
|
917
|
+
if (!objectProtoHasOwnProperty.call(objB, key) || !eq(objA[key], objB[key], strictCheck)) {
|
|
912
918
|
return false;
|
|
919
|
+
}
|
|
913
920
|
}
|
|
914
921
|
return true;
|
|
915
922
|
}
|
|
@@ -917,7 +924,7 @@
|
|
|
917
924
|
function memoize(func, options) {
|
|
918
925
|
var opts = options || {};
|
|
919
926
|
var max = mathCeil(opts.max || 0);
|
|
920
|
-
var isEqual = typeof opts.isEqual === 'function' ? opts.isEqual :
|
|
927
|
+
var isEqual = typeof opts.isEqual === 'function' ? opts.isEqual : shallowEqual;
|
|
921
928
|
var cache = [];
|
|
922
929
|
function memoized() {
|
|
923
930
|
var _this = this;
|
|
@@ -2055,6 +2062,8 @@
|
|
|
2055
2062
|
};
|
|
2056
2063
|
}
|
|
2057
2064
|
|
|
2065
|
+
var equalArrayLike = shallowEqual;
|
|
2066
|
+
|
|
2058
2067
|
var gt = createOperation(baseGt);
|
|
2059
2068
|
|
|
2060
2069
|
var gte = createOperation(baseGte);
|
|
@@ -2353,6 +2362,7 @@
|
|
|
2353
2362
|
exports.root = root;
|
|
2354
2363
|
exports.round = round;
|
|
2355
2364
|
exports.set = set;
|
|
2365
|
+
exports.shallowEqual = shallowEqual;
|
|
2356
2366
|
exports.shuffle = shuffle;
|
|
2357
2367
|
exports.sleep = sleep;
|
|
2358
2368
|
exports.snakeCase = snakeCase;
|