ut2 1.20.0 → 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 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.20.0";
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';
@@ -616,12 +616,12 @@
616
616
  try {
617
617
  return functionProtoToString.call(func);
618
618
  }
619
- catch (e) {
619
+ catch (err) {
620
620
  }
621
621
  try {
622
622
  return func + '';
623
623
  }
624
- catch (e) {
624
+ catch (err) {
625
625
  }
626
626
  }
627
627
  return '';
@@ -748,9 +748,7 @@
748
748
  if (timer !== nativeUndefined) {
749
749
  clearTimeout(timer);
750
750
  timer = nativeUndefined;
751
- if (lastArgs) {
752
- return invokeFunc(Date.now());
753
- }
751
+ return invokeFunc(Date.now());
754
752
  }
755
753
  return result;
756
754
  }
@@ -901,17 +899,24 @@
901
899
  return limited;
902
900
  }
903
901
 
904
- function equalArrayLike(arg1, arg2, strictCheck) {
902
+ function shallowEqual(objA, objB, strictCheck) {
905
903
  if (strictCheck === void 0) { strictCheck = true; }
906
- if (eq(arg1, arg2, strictCheck))
904
+ if (eq(objA, objB, strictCheck)) {
907
905
  return true;
908
- if (!isArrayLike(arg1) || !isArrayLike(arg2))
906
+ }
907
+ if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
909
908
  return false;
910
- if (arg1.length !== arg2.length)
909
+ }
910
+ var keysA = Object.keys(objA);
911
+ var keysB = Object.keys(objB);
912
+ if (keysA.length !== keysB.length) {
911
913
  return false;
912
- for (var i = 0; i < arg1.length; i++) {
913
- if (!eq(arg1[i], arg2[i], strictCheck))
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)) {
914
918
  return false;
919
+ }
915
920
  }
916
921
  return true;
917
922
  }
@@ -919,7 +924,7 @@
919
924
  function memoize(func, options) {
920
925
  var opts = options || {};
921
926
  var max = mathCeil(opts.max || 0);
922
- var isEqual = typeof opts.isEqual === 'function' ? opts.isEqual : equalArrayLike;
927
+ var isEqual = typeof opts.isEqual === 'function' ? opts.isEqual : shallowEqual;
923
928
  var cache = [];
924
929
  function memoized() {
925
930
  var _this = this;
@@ -1004,7 +1009,7 @@
1004
1009
  return types;
1005
1010
  }
1006
1011
  }
1007
- catch (e) {
1012
+ catch (err) {
1008
1013
  }
1009
1014
  })();
1010
1015
  var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer;
@@ -1925,7 +1930,7 @@
1925
1930
  return isNil(parent) ? true : delete parent[nth(paths, -1)];
1926
1931
  }
1927
1932
 
1928
- var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
1933
+ var reAsciiWord = /[^\x20-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
1929
1934
  function words(string, pattern) {
1930
1935
  if (pattern === void 0) { pattern = reAsciiWord; }
1931
1936
  return string.match(pattern) || [];
@@ -2057,6 +2062,8 @@
2057
2062
  };
2058
2063
  }
2059
2064
 
2065
+ var equalArrayLike = shallowEqual;
2066
+
2060
2067
  var gt = createOperation(baseGt);
2061
2068
 
2062
2069
  var gte = createOperation(baseGte);
@@ -2355,6 +2362,7 @@
2355
2362
  exports.root = root;
2356
2363
  exports.round = round;
2357
2364
  exports.set = set;
2365
+ exports.shallowEqual = shallowEqual;
2358
2366
  exports.shuffle = shuffle;
2359
2367
  exports.sleep = sleep;
2360
2368
  exports.snakeCase = snakeCase;