ut2 1.8.1 → 1.9.1

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 (67) hide show
  1. package/dist/ut2.js +63 -93
  2. package/dist/ut2.js.map +1 -1
  3. package/dist/ut2.min.js +1 -1
  4. package/dist/ut2.min.js.map +1 -1
  5. package/es/countBy.js +2 -2
  6. package/es/groupBy.js +2 -2
  7. package/es/internals/compare.js +19 -26
  8. package/es/internals/createExtremum.js +2 -2
  9. package/es/internals/createForEach.js +2 -2
  10. package/es/internals/createReduce.js +2 -2
  11. package/es/internals/helpers.js +1 -1
  12. package/es/invert.js +2 -2
  13. package/es/isEmpty.js +2 -2
  14. package/es/keyBy.js +2 -2
  15. package/es/max.js +4 -3
  16. package/es/merge.js +2 -2
  17. package/es/min.js +4 -3
  18. package/es/orderBy.js +2 -2
  19. package/es/partition.js +2 -2
  20. package/es/pick.js +4 -0
  21. package/es/pickBy.js +0 -4
  22. package/lib/countBy.js +2 -2
  23. package/lib/groupBy.js +2 -2
  24. package/lib/internals/compare.js +18 -27
  25. package/lib/internals/createExtremum.js +2 -2
  26. package/lib/internals/createForEach.js +2 -2
  27. package/lib/internals/createReduce.js +2 -2
  28. package/lib/internals/helpers.js +1 -1
  29. package/lib/invert.js +2 -2
  30. package/lib/isEmpty.js +2 -2
  31. package/lib/keyBy.js +2 -2
  32. package/lib/max.js +4 -3
  33. package/lib/merge.js +2 -2
  34. package/lib/min.js +4 -3
  35. package/lib/orderBy.js +2 -2
  36. package/lib/partition.js +2 -2
  37. package/lib/pick.js +4 -0
  38. package/lib/pickBy.js +0 -4
  39. package/package.json +1 -1
  40. package/types/countBy.d.ts +7 -5
  41. package/types/difference.d.ts +2 -2
  42. package/types/groupBy.d.ts +7 -5
  43. package/types/internals/compare.d.ts +0 -2
  44. package/types/internals/createExtremum.d.ts +2 -2
  45. package/types/internals/types.d.ts +9 -2
  46. package/types/intersection.d.ts +3 -3
  47. package/types/invert.d.ts +1 -1
  48. package/types/keyBy.d.ts +7 -5
  49. package/types/max.d.ts +5 -5
  50. package/types/merge.d.ts +3 -3
  51. package/types/min.d.ts +4 -4
  52. package/types/omitBy.d.ts +1 -1
  53. package/types/orderBy.d.ts +7 -5
  54. package/types/partition.d.ts +7 -5
  55. package/types/pickBy.d.ts +1 -1
  56. package/types/reduce.d.ts +1 -1
  57. package/types/reduceRight.d.ts +1 -1
  58. package/types/times.d.ts +1 -1
  59. package/types/union.d.ts +2 -2
  60. package/types/uniq.d.ts +2 -2
  61. package/types/xor.d.ts +3 -3
  62. package/es/internals/isPrototype.js +0 -12
  63. package/es/internals/specialKeys.js +0 -17
  64. package/lib/internals/isPrototype.js +0 -14
  65. package/lib/internals/specialKeys.js +0 -19
  66. package/types/internals/isPrototype.d.ts +0 -9
  67. package/types/internals/specialKeys.d.ts +0 -9
package/es/countBy.js CHANGED
@@ -4,8 +4,8 @@ import createIteratee from './internals/createIteratee.js';
4
4
  var countBy = function (collection, iteratee) {
5
5
  var result = {};
6
6
  var internalIteratee = createIteratee(iteratee);
7
- forEach(collection, function (item) {
8
- var key = internalIteratee(item);
7
+ forEach(collection, function (item, index, arr) {
8
+ var key = internalIteratee(item, index, arr);
9
9
  if (key in result) {
10
10
  ++result[key];
11
11
  }
package/es/groupBy.js CHANGED
@@ -6,8 +6,8 @@ var groupBy = function (collection, iteratee) {
6
6
  if (iteratee === void 0) { iteratee = identity; }
7
7
  var result = {};
8
8
  var internalIteratee = createIteratee(iteratee);
9
- forEach(collection, function (item) {
10
- var key = internalIteratee(item);
9
+ forEach(collection, function (item, index, arr) {
10
+ var key = internalIteratee(item, index, arr);
11
11
  if (key in result) {
12
12
  result[key].push(item);
13
13
  }
@@ -1,31 +1,24 @@
1
+ import isNumber from '../isNumber.js';
1
2
  import isSymbol from '../isSymbol.js';
2
3
  import toString from '../toString.js';
3
4
 
4
- function compareAsc(value, other) {
5
- var valueIsSymbol = isSymbol(value);
6
- var otherIsSymbol = isSymbol(other);
7
- var valueStr = toString(value);
8
- var otherStr = toString(other);
9
- if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
10
- return 1;
11
- }
12
- if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
13
- return -1;
14
- }
15
- return 0;
16
- }
17
- function compareDesc(value, other) {
18
- var valueIsSymbol = isSymbol(value);
19
- var otherIsSymbol = isSymbol(other);
20
- var valueStr = toString(value);
21
- var otherStr = toString(other);
22
- if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
23
- return -1;
24
- }
25
- if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
26
- return 1;
5
+ function createCompare(dir) {
6
+ var asc = dir === 1;
7
+ function wrapper(value, other) {
8
+ var valueIsSymbol = isSymbol(value);
9
+ var otherIsSymbol = isSymbol(other);
10
+ var isNeedConvertString = !valueIsSymbol && !otherIsSymbol && !(isNumber(value) && isNumber(other));
11
+ var _value = isNeedConvertString ? toString(value) : value;
12
+ var _other = isNeedConvertString ? toString(other) : other;
13
+ if (!otherIsSymbol && (valueIsSymbol || _value > _other)) {
14
+ return asc ? 1 : -1;
15
+ }
16
+ if (!valueIsSymbol && (otherIsSymbol || _value < _other)) {
17
+ return asc ? -1 : 1;
18
+ }
19
+ return 0;
27
20
  }
28
- return 0;
21
+ return wrapper;
29
22
  }
30
23
  function compareMultiple(object, other, orders) {
31
24
  var objCriteria = object.criteria;
@@ -34,7 +27,7 @@ function compareMultiple(object, other, orders) {
34
27
  var index = -1;
35
28
  while (++index < length) {
36
29
  var order = orders[index];
37
- var cmpFn = typeof order === 'function' ? order : order === 'desc' ? compareDesc : compareAsc;
30
+ var cmpFn = typeof order === 'function' ? order : order === 'desc' ? createCompare(0) : createCompare(1);
38
31
  var result = cmpFn(objCriteria[index], othCriteria[index]);
39
32
  if (result) {
40
33
  return result;
@@ -43,4 +36,4 @@ function compareMultiple(object, other, orders) {
43
36
  return object.index - other.index;
44
37
  }
45
38
 
46
- export { compareAsc, compareDesc, compareMultiple };
39
+ export { compareMultiple };
@@ -9,8 +9,8 @@ function createExtremum(array, comparator, iteratee) {
9
9
  }
10
10
  var result, computed;
11
11
  var internalIteratee = createIteratee(iteratee);
12
- array.forEach(function (value) {
13
- var current = internalIteratee(value);
12
+ array.forEach(function (value, index) {
13
+ var current = internalIteratee(value, index, array);
14
14
  if (current != null && (computed === nativeUndefined ? current === current && !isSymbol(current) : comparator(current, computed))) {
15
15
  computed = current;
16
16
  result = value;
@@ -1,11 +1,11 @@
1
+ import allKeys from '../allKeys.js';
1
2
  import identity from '../identity.js';
2
3
  import isArrayLike from '../isArrayLike.js';
3
- import keys from '../keys.js';
4
4
 
5
5
  function createForEach(dir) {
6
6
  var forEach = function (collection, iteratee) {
7
7
  if (iteratee === void 0) { iteratee = identity; }
8
- var _keys = !isArrayLike(collection) && keys(collection);
8
+ var _keys = !isArrayLike(collection) && allKeys(collection);
9
9
  var len = (_keys || collection).length;
10
10
  var i = dir > 0 ? 0 : len - 1;
11
11
  while (i >= 0 && i < len) {
@@ -1,10 +1,10 @@
1
+ import allKeys from '../allKeys.js';
1
2
  import identity from '../identity.js';
2
3
  import isArrayLike from '../isArrayLike.js';
3
- import keys from '../keys.js';
4
4
 
5
5
  function createReduce(dir) {
6
6
  function reducer(collection, iteratee, memo, initial) {
7
- var _keys = !isArrayLike(collection) && keys(collection);
7
+ var _keys = !isArrayLike(collection) && allKeys(collection);
8
8
  var len = (_keys || collection).length;
9
9
  var i = dir > 0 ? 0 : len - 1;
10
10
  if (!initial && len > 0) {
@@ -1,7 +1,7 @@
1
1
  import getTag from './getTag.js';
2
2
  import { argumentsTag, functionProtoToString } from './native.js';
3
3
 
4
- var VERSION = "1.8.1";
4
+ var VERSION = "1.9.1";
5
5
  var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
6
6
  var FUNC_ERROR_TEXT = 'Expected a function';
7
7
  function toSource(func) {
package/es/invert.js CHANGED
@@ -1,10 +1,10 @@
1
+ import allKeys from './allKeys.js';
1
2
  import { stubTrue } from './internals/helpers.js';
2
3
  import { objectProtoToString } from './internals/native.js';
3
- import keys from './keys.js';
4
4
 
5
5
  function invert(object, predicate) {
6
6
  if (predicate === void 0) { predicate = stubTrue; }
7
- var _keys = keys(object);
7
+ var _keys = allKeys(object);
8
8
  var result = {};
9
9
  _keys.forEach(function (key) {
10
10
  var value = object[key];
package/es/isEmpty.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import getTag from './internals/getTag.js';
2
- import keys from './internals/specialKeys.js';
3
2
  import { mapTag, setTag } from './internals/native.js';
4
3
  import isArrayLike from './isArrayLike.js';
5
4
  import isNil from './isNil.js';
6
5
  import isObjectLike from './isObjectLike.js';
6
+ import allKeys from './allKeys.js';
7
7
 
8
8
  function isEmpty(value) {
9
9
  if (isNil(value)) {
@@ -14,7 +14,7 @@ function isEmpty(value) {
14
14
  return !value.size;
15
15
  }
16
16
  if (isObjectLike(value)) {
17
- return !keys(value).length;
17
+ return !allKeys(value).length;
18
18
  }
19
19
  if (isArrayLike(value)) {
20
20
  return !value.length;
package/es/keyBy.js CHANGED
@@ -6,8 +6,8 @@ var keyBy = function (collection, iteratee) {
6
6
  if (iteratee === void 0) { iteratee = identity; }
7
7
  var result = {};
8
8
  var internalIteratee = createIteratee(iteratee);
9
- forEach(collection, function (item) {
10
- var key = internalIteratee(item);
9
+ forEach(collection, function (item, index, arr) {
10
+ var key = internalIteratee(item, index, arr);
11
11
  result[key] = item;
12
12
  });
13
13
  return result;
package/es/max.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { baseGt } from './internals/comparator.js';
2
2
  import createExtremum from './internals/createExtremum.js';
3
3
 
4
- function max(array, iteratee) {
4
+ var max = function (array, iteratee) {
5
5
  return createExtremum(array, baseGt, iteratee);
6
- }
6
+ };
7
+ var max$1 = max;
7
8
 
8
- export { max as default };
9
+ export { max$1 as default };
package/es/merge.js CHANGED
@@ -1,9 +1,9 @@
1
- import keysIn from './keysIn.js';
2
1
  import isArray from './isArray.js';
3
2
  import isObject from './isObject.js';
4
3
  import isObjectLike from './isObjectLike.js';
5
4
  import isPlainObject from './isPlainObject.js';
6
5
  import { nativeUndefined } from './internals/native.js';
6
+ import allKeys from './allKeys.js';
7
7
 
8
8
  function baseMerge(object, source, getKeys, customizer, stack) {
9
9
  if (stack === void 0) { stack = new WeakMap(); }
@@ -48,7 +48,7 @@ function baseMerge(object, source, getKeys, customizer, stack) {
48
48
  return obj;
49
49
  }
50
50
  function merge(object, source, customizer, getKeys) {
51
- if (getKeys === void 0) { getKeys = keysIn; }
51
+ if (getKeys === void 0) { getKeys = allKeys; }
52
52
  return baseMerge(object, source, getKeys, customizer);
53
53
  }
54
54
 
package/es/min.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { baseLt } from './internals/comparator.js';
2
2
  import createExtremum from './internals/createExtremum.js';
3
3
 
4
- function min(array, iteratee) {
4
+ var min = function (array, iteratee) {
5
5
  return createExtremum(array, baseLt, iteratee);
6
- }
6
+ };
7
+ var min$1 = min;
7
8
 
8
- export { min as default };
9
+ export { min$1 as default };
package/es/orderBy.js CHANGED
@@ -10,8 +10,8 @@ var orderBy = function (collection, iteratees, orders) {
10
10
  iteratees = (isArray(iteratees) ? iteratees : iteratees !== nativeUndefined ? [iteratees] : [identity]);
11
11
  orders = (isArray(orders) ? orders : orders !== nativeUndefined ? [orders] : []);
12
12
  var index = -1;
13
- forEach(collection, function (item) {
14
- var criteria = iteratees.map(function (iteratee) { return createIteratee(iteratee)(item); });
13
+ forEach(collection, function (item, key, arr) {
14
+ var criteria = iteratees.map(function (iteratee) { return createIteratee(iteratee)(item, key, arr); });
15
15
  result.push({
16
16
  criteria: criteria,
17
17
  index: ++index,
package/es/partition.js CHANGED
@@ -6,8 +6,8 @@ var partition = function (collection, predicate) {
6
6
  if (predicate === void 0) { predicate = identity; }
7
7
  var result = [[], []];
8
8
  var internalIteratee = createIteratee(predicate);
9
- forEach(collection, function (item) {
10
- result[internalIteratee(item) ? 0 : 1].push(item);
9
+ forEach(collection, function (item, index, arr) {
10
+ result[internalIteratee(item, index, arr) ? 0 : 1].push(item);
11
11
  });
12
12
  return result;
13
13
  };
package/es/pick.js CHANGED
@@ -1,8 +1,12 @@
1
1
  import castArray from './castArray.js';
2
+ import isObject from './isObject.js';
2
3
 
3
4
  var pick = function (object, fields) {
4
5
  if (fields === void 0) { fields = []; }
5
6
  var result = {};
7
+ if (!isObject(object)) {
8
+ return result;
9
+ }
6
10
  var fieldArr = castArray(fields);
7
11
  fieldArr.forEach(function (field) {
8
12
  if (field in object) {
package/es/pickBy.js CHANGED
@@ -1,13 +1,9 @@
1
1
  import allKeysIn from './allKeysIn.js';
2
2
  import { stubFlase } from './internals/helpers.js';
3
- import isNil from './isNil.js';
4
3
 
5
4
  function pickBy(object, predicate) {
6
5
  if (predicate === void 0) { predicate = stubFlase; }
7
6
  var result = {};
8
- if (isNil(object)) {
9
- return result;
10
- }
11
7
  var keys = allKeysIn(object);
12
8
  keys.forEach(function (key) {
13
9
  if (predicate(object[key], key)) {
package/lib/countBy.js CHANGED
@@ -6,8 +6,8 @@ var createIteratee = require('./internals/createIteratee.js');
6
6
  var countBy = function (collection, iteratee) {
7
7
  var result = {};
8
8
  var internalIteratee = createIteratee(iteratee);
9
- forEach(collection, function (item) {
10
- var key = internalIteratee(item);
9
+ forEach(collection, function (item, index, arr) {
10
+ var key = internalIteratee(item, index, arr);
11
11
  if (key in result) {
12
12
  ++result[key];
13
13
  }
package/lib/groupBy.js CHANGED
@@ -8,8 +8,8 @@ var groupBy = function (collection, iteratee) {
8
8
  if (iteratee === void 0) { iteratee = identity; }
9
9
  var result = {};
10
10
  var internalIteratee = createIteratee(iteratee);
11
- forEach(collection, function (item) {
12
- var key = internalIteratee(item);
11
+ forEach(collection, function (item, index, arr) {
12
+ var key = internalIteratee(item, index, arr);
13
13
  if (key in result) {
14
14
  result[key].push(item);
15
15
  }
@@ -1,33 +1,26 @@
1
1
  'use strict';
2
2
 
3
+ var isNumber = require('../isNumber.js');
3
4
  var isSymbol = require('../isSymbol.js');
4
5
  var toString = require('../toString.js');
5
6
 
6
- function compareAsc(value, other) {
7
- var valueIsSymbol = isSymbol(value);
8
- var otherIsSymbol = isSymbol(other);
9
- var valueStr = toString(value);
10
- var otherStr = toString(other);
11
- if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
12
- return 1;
13
- }
14
- if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
15
- return -1;
16
- }
17
- return 0;
18
- }
19
- function compareDesc(value, other) {
20
- var valueIsSymbol = isSymbol(value);
21
- var otherIsSymbol = isSymbol(other);
22
- var valueStr = toString(value);
23
- var otherStr = toString(other);
24
- if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
25
- return -1;
26
- }
27
- if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
28
- return 1;
7
+ function createCompare(dir) {
8
+ var asc = dir === 1;
9
+ function wrapper(value, other) {
10
+ var valueIsSymbol = isSymbol(value);
11
+ var otherIsSymbol = isSymbol(other);
12
+ var isNeedConvertString = !valueIsSymbol && !otherIsSymbol && !(isNumber(value) && isNumber(other));
13
+ var _value = isNeedConvertString ? toString(value) : value;
14
+ var _other = isNeedConvertString ? toString(other) : other;
15
+ if (!otherIsSymbol && (valueIsSymbol || _value > _other)) {
16
+ return asc ? 1 : -1;
17
+ }
18
+ if (!valueIsSymbol && (otherIsSymbol || _value < _other)) {
19
+ return asc ? -1 : 1;
20
+ }
21
+ return 0;
29
22
  }
30
- return 0;
23
+ return wrapper;
31
24
  }
32
25
  function compareMultiple(object, other, orders) {
33
26
  var objCriteria = object.criteria;
@@ -36,7 +29,7 @@ function compareMultiple(object, other, orders) {
36
29
  var index = -1;
37
30
  while (++index < length) {
38
31
  var order = orders[index];
39
- var cmpFn = typeof order === 'function' ? order : order === 'desc' ? compareDesc : compareAsc;
32
+ var cmpFn = typeof order === 'function' ? order : order === 'desc' ? createCompare(0) : createCompare(1);
40
33
  var result = cmpFn(objCriteria[index], othCriteria[index]);
41
34
  if (result) {
42
35
  return result;
@@ -45,6 +38,4 @@ function compareMultiple(object, other, orders) {
45
38
  return object.index - other.index;
46
39
  }
47
40
 
48
- exports.compareAsc = compareAsc;
49
- exports.compareDesc = compareDesc;
50
41
  exports.compareMultiple = compareMultiple;
@@ -11,8 +11,8 @@ function createExtremum(array, comparator, iteratee) {
11
11
  }
12
12
  var result, computed;
13
13
  var internalIteratee = createIteratee(iteratee);
14
- array.forEach(function (value) {
15
- var current = internalIteratee(value);
14
+ array.forEach(function (value, index) {
15
+ var current = internalIteratee(value, index, array);
16
16
  if (current != null && (computed === native.nativeUndefined ? current === current && !isSymbol(current) : comparator(current, computed))) {
17
17
  computed = current;
18
18
  result = value;
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
+ var allKeys = require('../allKeys.js');
3
4
  var identity = require('../identity.js');
4
5
  var isArrayLike = require('../isArrayLike.js');
5
- var keys = require('../keys.js');
6
6
 
7
7
  function createForEach(dir) {
8
8
  var forEach = function (collection, iteratee) {
9
9
  if (iteratee === void 0) { iteratee = identity; }
10
- var _keys = !isArrayLike(collection) && keys(collection);
10
+ var _keys = !isArrayLike(collection) && allKeys(collection);
11
11
  var len = (_keys || collection).length;
12
12
  var i = dir > 0 ? 0 : len - 1;
13
13
  while (i >= 0 && i < len) {
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ var allKeys = require('../allKeys.js');
3
4
  var identity = require('../identity.js');
4
5
  var isArrayLike = require('../isArrayLike.js');
5
- var keys = require('../keys.js');
6
6
 
7
7
  function createReduce(dir) {
8
8
  function reducer(collection, iteratee, memo, initial) {
9
- var _keys = !isArrayLike(collection) && keys(collection);
9
+ var _keys = !isArrayLike(collection) && allKeys(collection);
10
10
  var len = (_keys || collection).length;
11
11
  var i = dir > 0 ? 0 : len - 1;
12
12
  if (!initial && len > 0) {
@@ -3,7 +3,7 @@
3
3
  var getTag = require('./getTag.js');
4
4
  var native = require('./native.js');
5
5
 
6
- exports.VERSION = "1.8.1";
6
+ exports.VERSION = "1.9.1";
7
7
  exports.supportedArgumentsType = getTag((function () { return arguments; })()) === native.argumentsTag;
8
8
  exports.FUNC_ERROR_TEXT = 'Expected a function';
9
9
  function toSource(func) {
package/lib/invert.js CHANGED
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ var allKeys = require('./allKeys.js');
3
4
  var helpers = require('./internals/helpers.js');
4
5
  var native = require('./internals/native.js');
5
- var keys = require('./keys.js');
6
6
 
7
7
  function invert(object, predicate) {
8
8
  if (predicate === void 0) { predicate = helpers.stubTrue; }
9
- var _keys = keys(object);
9
+ var _keys = allKeys(object);
10
10
  var result = {};
11
11
  _keys.forEach(function (key) {
12
12
  var value = object[key];
package/lib/isEmpty.js CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var getTag = require('./internals/getTag.js');
4
- var specialKeys = require('./internals/specialKeys.js');
5
4
  var native = require('./internals/native.js');
6
5
  var isArrayLike = require('./isArrayLike.js');
7
6
  var isNil = require('./isNil.js');
8
7
  var isObjectLike = require('./isObjectLike.js');
8
+ var allKeys = require('./allKeys.js');
9
9
 
10
10
  function isEmpty(value) {
11
11
  if (isNil(value)) {
@@ -16,7 +16,7 @@ function isEmpty(value) {
16
16
  return !value.size;
17
17
  }
18
18
  if (isObjectLike(value)) {
19
- return !specialKeys(value).length;
19
+ return !allKeys(value).length;
20
20
  }
21
21
  if (isArrayLike(value)) {
22
22
  return !value.length;
package/lib/keyBy.js CHANGED
@@ -8,8 +8,8 @@ var keyBy = function (collection, iteratee) {
8
8
  if (iteratee === void 0) { iteratee = identity; }
9
9
  var result = {};
10
10
  var internalIteratee = createIteratee(iteratee);
11
- forEach(collection, function (item) {
12
- var key = internalIteratee(item);
11
+ forEach(collection, function (item, index, arr) {
12
+ var key = internalIteratee(item, index, arr);
13
13
  result[key] = item;
14
14
  });
15
15
  return result;
package/lib/max.js CHANGED
@@ -3,8 +3,9 @@
3
3
  var comparator = require('./internals/comparator.js');
4
4
  var createExtremum = require('./internals/createExtremum.js');
5
5
 
6
- function max(array, iteratee) {
6
+ var max = function (array, iteratee) {
7
7
  return createExtremum(array, comparator.baseGt, iteratee);
8
- }
8
+ };
9
+ var max$1 = max;
9
10
 
10
- module.exports = max;
11
+ module.exports = max$1;
package/lib/merge.js CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var keysIn = require('./keysIn.js');
4
3
  var isArray = require('./isArray.js');
5
4
  var isObject = require('./isObject.js');
6
5
  var isObjectLike = require('./isObjectLike.js');
7
6
  var isPlainObject = require('./isPlainObject.js');
8
7
  var native = require('./internals/native.js');
8
+ var allKeys = require('./allKeys.js');
9
9
 
10
10
  function baseMerge(object, source, getKeys, customizer, stack) {
11
11
  if (stack === void 0) { stack = new WeakMap(); }
@@ -50,7 +50,7 @@ function baseMerge(object, source, getKeys, customizer, stack) {
50
50
  return obj;
51
51
  }
52
52
  function merge(object, source, customizer, getKeys) {
53
- if (getKeys === void 0) { getKeys = keysIn; }
53
+ if (getKeys === void 0) { getKeys = allKeys; }
54
54
  return baseMerge(object, source, getKeys, customizer);
55
55
  }
56
56
 
package/lib/min.js CHANGED
@@ -3,8 +3,9 @@
3
3
  var comparator = require('./internals/comparator.js');
4
4
  var createExtremum = require('./internals/createExtremum.js');
5
5
 
6
- function min(array, iteratee) {
6
+ var min = function (array, iteratee) {
7
7
  return createExtremum(array, comparator.baseLt, iteratee);
8
- }
8
+ };
9
+ var min$1 = min;
9
10
 
10
- module.exports = min;
11
+ module.exports = min$1;
package/lib/orderBy.js CHANGED
@@ -12,8 +12,8 @@ var orderBy = function (collection, iteratees, orders) {
12
12
  iteratees = (isArray(iteratees) ? iteratees : iteratees !== native.nativeUndefined ? [iteratees] : [identity]);
13
13
  orders = (isArray(orders) ? orders : orders !== native.nativeUndefined ? [orders] : []);
14
14
  var index = -1;
15
- forEach(collection, function (item) {
16
- var criteria = iteratees.map(function (iteratee) { return createIteratee(iteratee)(item); });
15
+ forEach(collection, function (item, key, arr) {
16
+ var criteria = iteratees.map(function (iteratee) { return createIteratee(iteratee)(item, key, arr); });
17
17
  result.push({
18
18
  criteria: criteria,
19
19
  index: ++index,
package/lib/partition.js CHANGED
@@ -8,8 +8,8 @@ var partition = function (collection, predicate) {
8
8
  if (predicate === void 0) { predicate = identity; }
9
9
  var result = [[], []];
10
10
  var internalIteratee = createIteratee(predicate);
11
- forEach(collection, function (item) {
12
- result[internalIteratee(item) ? 0 : 1].push(item);
11
+ forEach(collection, function (item, index, arr) {
12
+ result[internalIteratee(item, index, arr) ? 0 : 1].push(item);
13
13
  });
14
14
  return result;
15
15
  };
package/lib/pick.js CHANGED
@@ -1,10 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  var castArray = require('./castArray.js');
4
+ var isObject = require('./isObject.js');
4
5
 
5
6
  var pick = function (object, fields) {
6
7
  if (fields === void 0) { fields = []; }
7
8
  var result = {};
9
+ if (!isObject(object)) {
10
+ return result;
11
+ }
8
12
  var fieldArr = castArray(fields);
9
13
  fieldArr.forEach(function (field) {
10
14
  if (field in object) {
package/lib/pickBy.js CHANGED
@@ -2,14 +2,10 @@
2
2
 
3
3
  var allKeysIn = require('./allKeysIn.js');
4
4
  var helpers = require('./internals/helpers.js');
5
- var isNil = require('./isNil.js');
6
5
 
7
6
  function pickBy(object, predicate) {
8
7
  if (predicate === void 0) { predicate = helpers.stubFlase; }
9
8
  var result = {};
10
- if (isNil(object)) {
11
- return result;
12
- }
13
9
  var keys = allKeysIn(object);
14
10
  keys.forEach(function (key) {
15
11
  if (predicate(object[key], key)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ut2",
3
- "version": "1.8.1",
3
+ "version": "1.9.1",
4
4
  "author": "caijf",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -1,18 +1,20 @@
1
- import { CollectionList, CollectionObject, IterateeParam } from './internals/types';
1
+ import { ArrayLikeIterator, CollectionList, CollectionObject, ObjectIterator, PropertyName } from './internals/types';
2
2
  interface CountBy {
3
- <T>(collection: CollectionList<T>, iteratee?: IterateeParam<T>): Record<string, number>;
4
- <T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: IterateeParam<V>): Record<string, number>;
3
+ <T extends object>(collection: CollectionList<T>, iteratee?: ArrayLikeIterator<T, PropertyName> | keyof T): Record<PropertyName, number>;
4
+ <T>(collection: CollectionList<T>, iteratee?: ArrayLikeIterator<T, PropertyName> | PropertyName): Record<PropertyName, number>;
5
+ <T extends object>(collection: CollectionObject<T>, iteratee?: ObjectIterator<T, PropertyName> | keyof T): Record<PropertyName, number>;
6
+ <T extends object>(collection: CollectionObject<T>, iteratee?: PropertyName): Record<PropertyName, number>;
5
7
  }
6
8
  /**
7
9
  * 创建一个组成对象, `key` 是经过 `iteratee` 执行处理 `collection` 中每个元素后返回的结果,每个 `key` 对应的值是 `iteratee` 返回该 `key` 的次数。
8
10
  *
9
- * `iteratee` 调用时会传入 1 个参数 `value` 。
11
+ * `iteratee` 调用时会传入三个参数 `value` `index|key` `collection` 。
10
12
  *
11
13
  * @function
12
14
  * @alias module:Collection.countBy
13
15
  * @since 1.0.0
14
16
  * @param {ArrayLike<any> | object} collection 一个用来迭代的集合。
15
- * @param {Function | string} [iteratee=identity] 迭代函数,用来转换键。
17
+ * @param {Function | string | number | Symbol} [iteratee=identity] 迭代函数,用来转换键。
16
18
  * @returns {Object} 组成集合对象。
17
19
  * @example
18
20
  *