ut2 1.9.1 → 1.9.3

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 (125) hide show
  1. package/README.md +2 -2
  2. package/dist/ut2.js +13 -21
  3. package/dist/ut2.js.map +1 -1
  4. package/dist/ut2.min.js +1 -1
  5. package/dist/ut2.min.js.map +1 -1
  6. package/es/clamp.js +1 -2
  7. package/es/conforms.js +1 -2
  8. package/es/conformsTo.js +1 -2
  9. package/es/countBy.js +1 -2
  10. package/es/curry.js +1 -2
  11. package/es/defaultTo.js +1 -2
  12. package/es/escapeRegExp.js +1 -3
  13. package/es/every.js +1 -2
  14. package/es/filter.js +1 -2
  15. package/es/find.js +1 -2
  16. package/es/forEach.js +1 -2
  17. package/es/forEachRight.js +1 -2
  18. package/es/fromPairs.js +1 -2
  19. package/es/groupBy.js +1 -2
  20. package/es/gt.js +1 -2
  21. package/es/gte.js +1 -2
  22. package/es/internals/helpers.js +1 -1
  23. package/es/internals/native.js +1 -2
  24. package/es/internals/root.js +1 -2
  25. package/es/isObject.js +3 -2
  26. package/es/isPlainObject.js +1 -1
  27. package/es/isTypedArray.js +2 -3
  28. package/es/keyBy.js +1 -2
  29. package/es/lowerFirst.js +1 -2
  30. package/es/lt.js +1 -2
  31. package/es/lte.js +1 -2
  32. package/es/map.js +1 -2
  33. package/es/max.js +1 -2
  34. package/es/min.js +1 -2
  35. package/es/omit.js +1 -2
  36. package/es/orderBy.js +1 -2
  37. package/es/partial.js +1 -2
  38. package/es/partition.js +1 -2
  39. package/es/pick.js +1 -2
  40. package/es/random.js +1 -1
  41. package/es/randomInt.js +1 -1
  42. package/es/range.js +1 -2
  43. package/es/reduce.js +1 -2
  44. package/es/reduceRight.js +1 -2
  45. package/es/some.js +1 -2
  46. package/es/times.js +1 -2
  47. package/es/toNumber.js +1 -5
  48. package/es/uniqueId.js +4 -4
  49. package/es/upperFirst.js +1 -2
  50. package/lib/clamp.js +1 -2
  51. package/lib/conforms.js +1 -2
  52. package/lib/conformsTo.js +1 -2
  53. package/lib/countBy.js +1 -2
  54. package/lib/curry.js +1 -2
  55. package/lib/defaultTo.js +1 -2
  56. package/lib/escapeRegExp.js +1 -3
  57. package/lib/every.js +1 -2
  58. package/lib/filter.js +1 -2
  59. package/lib/find.js +1 -2
  60. package/lib/forEach.js +1 -2
  61. package/lib/forEachRight.js +1 -2
  62. package/lib/fromPairs.js +1 -2
  63. package/lib/groupBy.js +1 -2
  64. package/lib/gt.js +1 -2
  65. package/lib/gte.js +1 -2
  66. package/lib/index.js +4 -16
  67. package/lib/internals/comparator.js +8 -4
  68. package/lib/internals/helpers.js +10 -5
  69. package/lib/internals/native.js +104 -53
  70. package/lib/internals/nodeUtil.js +13 -6
  71. package/lib/internals/root.js +1 -2
  72. package/lib/isObject.js +3 -2
  73. package/lib/isTypedArray.js +2 -3
  74. package/lib/keyBy.js +1 -2
  75. package/lib/lowerFirst.js +1 -2
  76. package/lib/lt.js +1 -2
  77. package/lib/lte.js +1 -2
  78. package/lib/map.js +1 -2
  79. package/lib/max.js +1 -2
  80. package/lib/min.js +1 -2
  81. package/lib/omit.js +1 -2
  82. package/lib/orderBy.js +1 -2
  83. package/lib/partial.js +1 -2
  84. package/lib/partition.js +1 -2
  85. package/lib/pick.js +1 -2
  86. package/lib/range.js +1 -2
  87. package/lib/reduce.js +1 -2
  88. package/lib/reduceRight.js +1 -2
  89. package/lib/some.js +1 -2
  90. package/lib/times.js +1 -2
  91. package/lib/toNumber.js +1 -5
  92. package/lib/uniqueId.js +4 -4
  93. package/lib/upperFirst.js +1 -2
  94. package/package.json +19 -19
  95. package/types/camelCase.d.ts +1 -1
  96. package/types/ceil.d.ts +1 -1
  97. package/types/compact.d.ts +1 -1
  98. package/types/delay.d.ts +0 -1
  99. package/types/eq.d.ts +1 -1
  100. package/types/escape.d.ts +1 -1
  101. package/types/escapeRegExp.d.ts +1 -1
  102. package/types/floor.d.ts +1 -1
  103. package/types/internals/native.d.ts +4 -5
  104. package/types/isArrayLikeObject.d.ts +1 -1
  105. package/types/isBlob.d.ts +2 -2
  106. package/types/isBuffer.d.ts +0 -1
  107. package/types/isElement.d.ts +1 -1
  108. package/types/isLength.d.ts +1 -1
  109. package/types/isObject.d.ts +3 -2
  110. package/types/isObjectLike.d.ts +1 -1
  111. package/types/isPlainObject.d.ts +1 -1
  112. package/types/isPromiseLike.d.ts +6 -1
  113. package/types/isTypedArray.d.ts +1 -1
  114. package/types/kebabCase.d.ts +1 -1
  115. package/types/merge.d.ts +1 -1
  116. package/types/orderBy.d.ts +1 -1
  117. package/types/pascalCase.d.ts +1 -1
  118. package/types/random.d.ts +10 -6
  119. package/types/randomInt.d.ts +9 -5
  120. package/types/round.d.ts +1 -1
  121. package/types/snakeCase.d.ts +1 -1
  122. package/types/toLength.d.ts +1 -1
  123. package/types/uniqueId.d.ts +3 -3
  124. package/types/words.d.ts +1 -1
  125. package/types/xor.d.ts +1 -1
package/README.md CHANGED
@@ -151,10 +151,10 @@ const debounced = debounce(() => {
151
151
  - [Object](https://caijf.github.io/ut2/module-Object.html) 对象
152
152
  - [allKeys](https://caijf.github.io/ut2/module-Object.html#.allKeys) - 对象自身的可枚举属性(包含 `Symbol` 属性)。
153
153
  - [allKeysIn](https://caijf.github.io/ut2/module-Object.html#.allKeysIn) - 对象自身及继承的可枚举属性(包含 `Symbol` 属性)。
154
- - [invert](https://caijf.github.io/ut2/module-Object.html#.invert) - 对象自身的可枚举属性(不包含 `Symbol` 属性)和值反转。
154
+ - [invert](https://caijf.github.io/ut2/module-Object.html#.invert) - 对象自身的可枚举属性(包含 `Symbol` 属性)和值反转。
155
155
  - [keys](https://caijf.github.io/ut2/module-Object.html#.keys) - 对象自身的可枚举属性(不包含 `Symbol` 属性)。
156
156
  - [keysIn](https://caijf.github.io/ut2/module-Object.html#.keysIn) - 对象自身及继承的可枚举属性(不包含 `Symbol` 属性)。
157
- - [merge](https://caijf.github.io/ut2/module-Object.html#.merge) - 递归对象或数组进行合并。
157
+ - [merge](https://caijf.github.io/ut2/module-Object.html#.merge) - 递归对象自身的可枚举属性(包含 `Symbol` 属性)或数组进行合并。
158
158
  - [omit](https://caijf.github.io/ut2/module-Object.html#.omit) - 排除部分属性。
159
159
  - [omitBy](https://caijf.github.io/ut2/module-Object.html#.omitBy) - 根据方法,排除部分属性。
160
160
  - [pick](https://caijf.github.io/ut2/module-Object.html#.pick) - 选择部分属性。
package/dist/ut2.js CHANGED
@@ -46,7 +46,6 @@
46
46
  var arrayBufferTag = '[object ArrayBuffer]';
47
47
  var argumentsTag = '[object Arguments]';
48
48
  var arrayTag = '[object Array]';
49
- var typedArrayTags = ['Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'BigInt64Array', 'BigUint64Array'].map(function (item) { return '[object ' + item + ']'; });
50
49
  var functionTags = ['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy'].map(function (item) { return '[object ' + item + ']'; });
51
50
  var weakSetTag = '[object WeakSet]';
52
51
  var blobTag = '[object Blob]';
@@ -62,9 +61,12 @@
62
61
  return Array.isArray(value);
63
62
  }
64
63
 
64
+ function isObjectLike(value) {
65
+ return value !== null && typeof value === 'object';
66
+ }
67
+
65
68
  function isObject(value) {
66
- var type = typeof value;
67
- return type === 'function' || (type === 'object' && !!value);
69
+ return typeof value === 'function' || isObjectLike(value);
68
70
  }
69
71
 
70
72
  function getTag(value) {
@@ -93,11 +95,7 @@
93
95
  }
94
96
  value = value.trim();
95
97
  var isBinary = reIsBinary.test(value);
96
- return isBinary || reIsOctal.test(value)
97
- ? parseInt(value.slice(2), isBinary ? 2 : 8)
98
- : reIsBadHex.test(value)
99
- ? NaN
100
- : +value;
98
+ return isBinary || reIsOctal.test(value) ? parseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NaN : +value;
101
99
  }
102
100
 
103
101
  function toInteger(value) {
@@ -299,10 +297,6 @@
299
297
  return uniq(array.concat(other), iteratee, strickCheck);
300
298
  }
301
299
 
302
- function isObjectLike(value) {
303
- return value !== null && typeof value === 'object';
304
- }
305
-
306
300
  function isArrayLikeObject(value) {
307
301
  return isObjectLike(value) && isArrayLike(value);
308
302
  }
@@ -605,7 +599,7 @@
605
599
  return value == null || value !== value ? defaultValue : value;
606
600
  };
607
601
 
608
- var VERSION = "1.9.1";
602
+ var VERSION = "1.9.3";
609
603
  var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
610
604
  var FUNC_ERROR_TEXT = 'Expected a function';
611
605
  function toSource(func) {
@@ -958,13 +952,13 @@
958
952
  return true;
959
953
  }
960
954
 
955
+ var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;
961
956
  function isTypedArray(value) {
962
957
  if (nodeIsTypedArray) {
963
958
  return nodeIsTypedArray(value);
964
959
  }
965
960
  if (isObjectLike(value) && isLength(value.length)) {
966
- var tag_1 = getTag(value);
967
- return typedArrayTags.some(function (item) { return item === tag_1; });
961
+ return typedArrayPattern.test(getTag(value));
968
962
  }
969
963
  return false;
970
964
  }
@@ -1603,9 +1597,7 @@
1603
1597
  var reRegExpChar = /[\\^$.*+?\-()[\]{}|]/g;
1604
1598
  var reHasRegExpChar = RegExp(reRegExpChar.source);
1605
1599
  function escapeRegExp(string) {
1606
- return string && reHasRegExpChar.test(string)
1607
- ? string.replace(reRegExpChar, '\\$&')
1608
- : string || '';
1600
+ return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar, '\\$&') : string || '';
1609
1601
  }
1610
1602
 
1611
1603
  function kebabCase(string, pattern) {
@@ -1765,10 +1757,10 @@
1765
1757
  }
1766
1758
 
1767
1759
  var idCounter = 0;
1760
+ var defaultPrefix = '_' + mathRandom().toString(36).substring(2, 4);
1768
1761
  function uniqueId(prefix) {
1769
- if (prefix === void 0) { prefix = ''; }
1770
- var id = ++idCounter;
1771
- return toString(prefix) + id;
1762
+ if (prefix === void 0) { prefix = defaultPrefix; }
1763
+ return '' + prefix + ++idCounter;
1772
1764
  }
1773
1765
 
1774
1766
  exports.MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH;