ut2 1.9.0 → 1.9.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.
Files changed (115) hide show
  1. package/README.md +2 -2
  2. package/dist/ut2.js +9 -15
  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/root.js +1 -2
  24. package/es/isPlainObject.js +1 -1
  25. package/es/keyBy.js +1 -2
  26. package/es/lowerFirst.js +1 -2
  27. package/es/lt.js +1 -2
  28. package/es/lte.js +1 -2
  29. package/es/map.js +1 -2
  30. package/es/max.js +1 -2
  31. package/es/min.js +1 -2
  32. package/es/omit.js +1 -2
  33. package/es/orderBy.js +1 -2
  34. package/es/partial.js +1 -2
  35. package/es/partition.js +1 -2
  36. package/es/pick.js +5 -2
  37. package/es/pickBy.js +0 -4
  38. package/es/random.js +1 -1
  39. package/es/randomInt.js +1 -1
  40. package/es/range.js +1 -2
  41. package/es/reduce.js +1 -2
  42. package/es/reduceRight.js +1 -2
  43. package/es/some.js +1 -2
  44. package/es/times.js +1 -2
  45. package/es/toNumber.js +1 -5
  46. package/es/uniqueId.js +3 -5
  47. package/es/upperFirst.js +1 -2
  48. package/lib/clamp.js +1 -2
  49. package/lib/conforms.js +1 -2
  50. package/lib/conformsTo.js +1 -2
  51. package/lib/countBy.js +1 -2
  52. package/lib/curry.js +1 -2
  53. package/lib/defaultTo.js +1 -2
  54. package/lib/escapeRegExp.js +1 -3
  55. package/lib/every.js +1 -2
  56. package/lib/filter.js +1 -2
  57. package/lib/find.js +1 -2
  58. package/lib/forEach.js +1 -2
  59. package/lib/forEachRight.js +1 -2
  60. package/lib/fromPairs.js +1 -2
  61. package/lib/groupBy.js +1 -2
  62. package/lib/gt.js +1 -2
  63. package/lib/gte.js +1 -2
  64. package/lib/index.js +4 -16
  65. package/lib/internals/comparator.js +8 -4
  66. package/lib/internals/helpers.js +10 -5
  67. package/lib/internals/native.js +106 -53
  68. package/lib/internals/nodeUtil.js +13 -6
  69. package/lib/internals/root.js +1 -2
  70. package/lib/keyBy.js +1 -2
  71. package/lib/lowerFirst.js +1 -2
  72. package/lib/lt.js +1 -2
  73. package/lib/lte.js +1 -2
  74. package/lib/map.js +1 -2
  75. package/lib/max.js +1 -2
  76. package/lib/min.js +1 -2
  77. package/lib/omit.js +1 -2
  78. package/lib/orderBy.js +1 -2
  79. package/lib/partial.js +1 -2
  80. package/lib/partition.js +1 -2
  81. package/lib/pick.js +5 -2
  82. package/lib/pickBy.js +0 -4
  83. package/lib/range.js +1 -2
  84. package/lib/reduce.js +1 -2
  85. package/lib/reduceRight.js +1 -2
  86. package/lib/some.js +1 -2
  87. package/lib/times.js +1 -2
  88. package/lib/toNumber.js +1 -5
  89. package/lib/uniqueId.js +3 -5
  90. package/lib/upperFirst.js +1 -2
  91. package/package.json +2 -2
  92. package/types/camelCase.d.ts +1 -1
  93. package/types/ceil.d.ts +1 -1
  94. package/types/compact.d.ts +1 -1
  95. package/types/eq.d.ts +1 -1
  96. package/types/escape.d.ts +1 -1
  97. package/types/escapeRegExp.d.ts +1 -1
  98. package/types/floor.d.ts +1 -1
  99. package/types/internals/native.d.ts +3 -3
  100. package/types/isBlob.d.ts +2 -2
  101. package/types/isLength.d.ts +1 -1
  102. package/types/isObject.d.ts +1 -1
  103. package/types/isTypedArray.d.ts +1 -1
  104. package/types/kebabCase.d.ts +1 -1
  105. package/types/merge.d.ts +1 -1
  106. package/types/orderBy.d.ts +1 -1
  107. package/types/pascalCase.d.ts +1 -1
  108. package/types/random.d.ts +10 -6
  109. package/types/randomInt.d.ts +9 -5
  110. package/types/round.d.ts +1 -1
  111. package/types/snakeCase.d.ts +1 -1
  112. package/types/toLength.d.ts +1 -1
  113. package/types/uniqueId.d.ts +3 -3
  114. package/types/words.d.ts +1 -1
  115. 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
@@ -93,11 +93,7 @@
93
93
  }
94
94
  value = value.trim();
95
95
  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;
96
+ return isBinary || reIsOctal.test(value) ? parseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NaN : +value;
101
97
  }
102
98
 
103
99
  function toInteger(value) {
@@ -605,7 +601,7 @@
605
601
  return value == null || value !== value ? defaultValue : value;
606
602
  };
607
603
 
608
- var VERSION = "1.9.0";
604
+ var VERSION = "1.9.2";
609
605
  var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
610
606
  var FUNC_ERROR_TEXT = 'Expected a function';
611
607
  function toSource(func) {
@@ -1520,9 +1516,6 @@
1520
1516
  function pickBy(object, predicate) {
1521
1517
  if (predicate === void 0) { predicate = stubFlase; }
1522
1518
  var result = {};
1523
- if (isNil(object)) {
1524
- return result;
1525
- }
1526
1519
  var keys = allKeysIn(object);
1527
1520
  keys.forEach(function (key) {
1528
1521
  if (predicate(object[key], key)) {
@@ -1540,6 +1533,9 @@
1540
1533
  var pick = function (object, fields) {
1541
1534
  if (fields === void 0) { fields = []; }
1542
1535
  var result = {};
1536
+ if (!isObject(object)) {
1537
+ return result;
1538
+ }
1543
1539
  var fieldArr = castArray(fields);
1544
1540
  fieldArr.forEach(function (field) {
1545
1541
  if (field in object) {
@@ -1603,9 +1599,7 @@
1603
1599
  var reRegExpChar = /[\\^$.*+?\-()[\]{}|]/g;
1604
1600
  var reHasRegExpChar = RegExp(reRegExpChar.source);
1605
1601
  function escapeRegExp(string) {
1606
- return string && reHasRegExpChar.test(string)
1607
- ? string.replace(reRegExpChar, '\\$&')
1608
- : string || '';
1602
+ return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar, '\\$&') : string || '';
1609
1603
  }
1610
1604
 
1611
1605
  function kebabCase(string, pattern) {
@@ -1765,10 +1759,10 @@
1765
1759
  }
1766
1760
 
1767
1761
  var idCounter = 0;
1762
+ var defaultPrefix = '_' + Math.random().toString(36).substring(2, 4);
1768
1763
  function uniqueId(prefix) {
1769
- if (prefix === void 0) { prefix = ''; }
1770
- var id = ++idCounter;
1771
- return toString(prefix) + id;
1764
+ if (prefix === void 0) { prefix = defaultPrefix; }
1765
+ return '' + prefix + ++idCounter;
1772
1766
  }
1773
1767
 
1774
1768
  exports.MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH;