ut2 1.8.1 → 1.9.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/dist/ut2.js +60 -90
- package/dist/ut2.js.map +1 -1
- package/dist/ut2.min.js +1 -1
- package/dist/ut2.min.js.map +1 -1
- package/es/countBy.js +2 -2
- package/es/groupBy.js +2 -2
- package/es/internals/compare.js +19 -26
- package/es/internals/createExtremum.js +2 -2
- package/es/internals/createForEach.js +2 -2
- package/es/internals/createReduce.js +2 -2
- package/es/internals/helpers.js +1 -1
- package/es/invert.js +2 -2
- package/es/isEmpty.js +2 -2
- package/es/keyBy.js +2 -2
- package/es/max.js +4 -3
- package/es/merge.js +2 -2
- package/es/min.js +4 -3
- package/es/orderBy.js +2 -2
- package/es/partition.js +2 -2
- package/lib/countBy.js +2 -2
- package/lib/groupBy.js +2 -2
- package/lib/internals/compare.js +18 -27
- package/lib/internals/createExtremum.js +2 -2
- package/lib/internals/createForEach.js +2 -2
- package/lib/internals/createReduce.js +2 -2
- package/lib/internals/helpers.js +1 -1
- package/lib/invert.js +2 -2
- package/lib/isEmpty.js +2 -2
- package/lib/keyBy.js +2 -2
- package/lib/max.js +4 -3
- package/lib/merge.js +2 -2
- package/lib/min.js +4 -3
- package/lib/orderBy.js +2 -2
- package/lib/partition.js +2 -2
- package/package.json +1 -1
- package/types/countBy.d.ts +7 -5
- package/types/difference.d.ts +2 -2
- package/types/groupBy.d.ts +7 -5
- package/types/internals/compare.d.ts +0 -2
- package/types/internals/createExtremum.d.ts +2 -2
- package/types/internals/types.d.ts +9 -2
- package/types/intersection.d.ts +3 -3
- package/types/invert.d.ts +1 -1
- package/types/keyBy.d.ts +7 -5
- package/types/max.d.ts +5 -5
- package/types/merge.d.ts +3 -3
- package/types/min.d.ts +4 -4
- package/types/omitBy.d.ts +1 -1
- package/types/orderBy.d.ts +7 -5
- package/types/partition.d.ts +7 -5
- package/types/pickBy.d.ts +1 -1
- package/types/reduce.d.ts +1 -1
- package/types/reduceRight.d.ts +1 -1
- package/types/times.d.ts +1 -1
- package/types/union.d.ts +2 -2
- package/types/uniq.d.ts +2 -2
- package/types/xor.d.ts +3 -3
- package/es/internals/isPrototype.js +0 -12
- package/es/internals/specialKeys.js +0 -17
- package/lib/internals/isPrototype.js +0 -14
- package/lib/internals/specialKeys.js +0 -19
- package/types/internals/isPrototype.d.ts +0 -9
- 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
|
}
|
package/es/internals/compare.js
CHANGED
|
@@ -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
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
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' ?
|
|
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 {
|
|
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) &&
|
|
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) &&
|
|
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) {
|
package/es/internals/helpers.js
CHANGED
|
@@ -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.
|
|
4
|
+
var VERSION = "1.9.0";
|
|
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 =
|
|
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 !
|
|
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
|
|
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 =
|
|
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
|
|
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/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
|
}
|
package/lib/internals/compare.js
CHANGED
|
@@ -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
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
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' ?
|
|
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) &&
|
|
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) &&
|
|
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) {
|
package/lib/internals/helpers.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var getTag = require('./getTag.js');
|
|
4
4
|
var native = require('./native.js');
|
|
5
5
|
|
|
6
|
-
exports.VERSION = "1.
|
|
6
|
+
exports.VERSION = "1.9.0";
|
|
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 =
|
|
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 !
|
|
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
|
|
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 =
|
|
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
|
|
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/package.json
CHANGED
package/types/countBy.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { CollectionList, CollectionObject,
|
|
1
|
+
import { ArrayLikeIterator, CollectionList, CollectionObject, ObjectIterator, PropertyName } from './internals/types';
|
|
2
2
|
interface CountBy {
|
|
3
|
-
<T>(collection: CollectionList<T>, iteratee?:
|
|
4
|
-
<T
|
|
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`
|
|
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
|
*
|
package/types/difference.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { IterateeParam } from './internals/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建一个 `array` 排除 `values` 值的新数组。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
|
|
4
4
|
*
|
|
5
|
-
* `iteratee`
|
|
5
|
+
* `iteratee` 调用时会传入一个参数 `value` 。
|
|
6
6
|
*
|
|
7
7
|
* 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
|
|
8
8
|
*
|
|
@@ -11,7 +11,7 @@ import { IterateeParam } from './internals/types';
|
|
|
11
11
|
* @since 1.0.0
|
|
12
12
|
* @param {Array} array 要检查的数组。
|
|
13
13
|
* @param {Array} values 排除的值。
|
|
14
|
-
* @param {Function | string} [iteratee=identity] 迭代函数,调用每个元素。
|
|
14
|
+
* @param {Function | string | number | Symbol} [iteratee=identity] 迭代函数,调用每个元素。
|
|
15
15
|
* @param {boolean} [strictCheck=false] 严格比较,区分 `0` `-0`,默认 `false` 。
|
|
16
16
|
* @returns {Array} 过滤值后的新数组。
|
|
17
17
|
* @example
|
package/types/groupBy.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { CollectionList, CollectionObject,
|
|
1
|
+
import { ArrayLikeIterator, CollectionList, CollectionObject, PropertyName, ObjectIterator } from './internals/types';
|
|
2
2
|
interface GroupBy {
|
|
3
|
-
<T>(collection: CollectionList<T>, iteratee?:
|
|
4
|
-
<T
|
|
3
|
+
<T extends object>(collection: CollectionList<T>, iteratee?: ArrayLikeIterator<T, PropertyName> | keyof T): Record<PropertyName, T[]>;
|
|
4
|
+
<T>(collection: CollectionList<T>, iteratee?: ArrayLikeIterator<T, PropertyName> | PropertyName): Record<PropertyName, T[]>;
|
|
5
|
+
<T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: ObjectIterator<T, PropertyName> | keyof T): Record<PropertyName, V[]>;
|
|
6
|
+
<T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: PropertyName): Record<PropertyName, V[]>;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* 创建一个组成聚合对象, `key` 是经过 `iteratee` 执行处理 `collection` 中每个元素后返回的结果。分组值的顺序是由他们出现在 `collection` 的顺序确定的。每个键对应的值负责生成 `key` 的元素组成的数组。
|
|
8
10
|
*
|
|
9
|
-
* `iteratee`
|
|
11
|
+
* `iteratee` 调用时会传入三个参数 `value` `index|key` `collection` 。
|
|
10
12
|
*
|
|
11
13
|
* @static
|
|
12
14
|
* @alias module:Collection.groupBy
|
|
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
|
*
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IterateeParam } from './types';
|
|
2
|
-
declare function createExtremum<T>(array: T[]
|
|
1
|
+
import { IterateeParam, WithNullable } from './types';
|
|
2
|
+
declare function createExtremum<T>(array: WithNullable<T[]>, comparator: (value: any, other: any) => boolean, iteratee?: IterateeParam<T>): T | undefined;
|
|
3
3
|
export default createExtremum;
|