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.
- package/dist/ut2.js +63 -93
- 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/es/pick.js +4 -0
- package/es/pickBy.js +0 -4
- 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/lib/pick.js +4 -0
- package/lib/pickBy.js +0 -4
- 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/dist/ut2.js
CHANGED
|
@@ -353,17 +353,24 @@
|
|
|
353
353
|
return unzip(arrays);
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
function
|
|
356
|
+
function getSymbols(object) {
|
|
357
|
+
if (!objectGetOwnPropertySymbols || object === null) {
|
|
358
|
+
return [];
|
|
359
|
+
}
|
|
360
|
+
return objectGetOwnPropertySymbols(object).filter(function (item) { return objectProtoPropertyIsEnumerable.call(object, item); });
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function allKeys(object) {
|
|
357
364
|
if (!isObject(object)) {
|
|
358
365
|
return [];
|
|
359
366
|
}
|
|
360
|
-
return objectKeys(object);
|
|
367
|
+
return objectKeys(object).concat(getSymbols(object));
|
|
361
368
|
}
|
|
362
369
|
|
|
363
370
|
function createForEach(dir) {
|
|
364
371
|
var forEach = function (collection, iteratee) {
|
|
365
372
|
if (iteratee === void 0) { iteratee = identity; }
|
|
366
|
-
var _keys = !isArrayLike(collection) &&
|
|
373
|
+
var _keys = !isArrayLike(collection) && allKeys(collection);
|
|
367
374
|
var len = (_keys || collection).length;
|
|
368
375
|
var i = dir > 0 ? 0 : len - 1;
|
|
369
376
|
while (i >= 0 && i < len) {
|
|
@@ -383,8 +390,8 @@
|
|
|
383
390
|
var countBy = function (collection, iteratee) {
|
|
384
391
|
var result = {};
|
|
385
392
|
var internalIteratee = createIteratee(iteratee);
|
|
386
|
-
forEach(collection, function (item) {
|
|
387
|
-
var key = internalIteratee(item);
|
|
393
|
+
forEach(collection, function (item, index, arr) {
|
|
394
|
+
var key = internalIteratee(item, index, arr);
|
|
388
395
|
if (key in result) {
|
|
389
396
|
++result[key];
|
|
390
397
|
}
|
|
@@ -436,8 +443,8 @@
|
|
|
436
443
|
if (iteratee === void 0) { iteratee = identity; }
|
|
437
444
|
var result = {};
|
|
438
445
|
var internalIteratee = createIteratee(iteratee);
|
|
439
|
-
forEach(collection, function (item) {
|
|
440
|
-
var key = internalIteratee(item);
|
|
446
|
+
forEach(collection, function (item, index, arr) {
|
|
447
|
+
var key = internalIteratee(item, index, arr);
|
|
441
448
|
if (key in result) {
|
|
442
449
|
result[key].push(item);
|
|
443
450
|
}
|
|
@@ -452,13 +459,17 @@
|
|
|
452
459
|
if (iteratee === void 0) { iteratee = identity; }
|
|
453
460
|
var result = {};
|
|
454
461
|
var internalIteratee = createIteratee(iteratee);
|
|
455
|
-
forEach(collection, function (item) {
|
|
456
|
-
var key = internalIteratee(item);
|
|
462
|
+
forEach(collection, function (item, index, arr) {
|
|
463
|
+
var key = internalIteratee(item, index, arr);
|
|
457
464
|
result[key] = item;
|
|
458
465
|
});
|
|
459
466
|
return result;
|
|
460
467
|
};
|
|
461
468
|
|
|
469
|
+
function isNumber(value) {
|
|
470
|
+
return typeof value === 'number' || getTag(value) === numberTag;
|
|
471
|
+
}
|
|
472
|
+
|
|
462
473
|
function isNil(value) {
|
|
463
474
|
return value == null;
|
|
464
475
|
}
|
|
@@ -481,31 +492,23 @@
|
|
|
481
492
|
return isNil(value) ? '' : baseToString(value);
|
|
482
493
|
}
|
|
483
494
|
|
|
484
|
-
function
|
|
485
|
-
var
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
var otherIsSymbol = isSymbol(other);
|
|
500
|
-
var valueStr = toString(value);
|
|
501
|
-
var otherStr = toString(other);
|
|
502
|
-
if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
|
|
503
|
-
return -1;
|
|
504
|
-
}
|
|
505
|
-
if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
|
|
506
|
-
return 1;
|
|
495
|
+
function createCompare(dir) {
|
|
496
|
+
var asc = dir === 1;
|
|
497
|
+
function wrapper(value, other) {
|
|
498
|
+
var valueIsSymbol = isSymbol(value);
|
|
499
|
+
var otherIsSymbol = isSymbol(other);
|
|
500
|
+
var isNeedConvertString = !valueIsSymbol && !otherIsSymbol && !(isNumber(value) && isNumber(other));
|
|
501
|
+
var _value = isNeedConvertString ? toString(value) : value;
|
|
502
|
+
var _other = isNeedConvertString ? toString(other) : other;
|
|
503
|
+
if (!otherIsSymbol && (valueIsSymbol || _value > _other)) {
|
|
504
|
+
return asc ? 1 : -1;
|
|
505
|
+
}
|
|
506
|
+
if (!valueIsSymbol && (otherIsSymbol || _value < _other)) {
|
|
507
|
+
return asc ? -1 : 1;
|
|
508
|
+
}
|
|
509
|
+
return 0;
|
|
507
510
|
}
|
|
508
|
-
return
|
|
511
|
+
return wrapper;
|
|
509
512
|
}
|
|
510
513
|
function compareMultiple(object, other, orders) {
|
|
511
514
|
var objCriteria = object.criteria;
|
|
@@ -514,7 +517,7 @@
|
|
|
514
517
|
var index = -1;
|
|
515
518
|
while (++index < length) {
|
|
516
519
|
var order = orders[index];
|
|
517
|
-
var cmpFn = typeof order === 'function' ? order : order === 'desc' ?
|
|
520
|
+
var cmpFn = typeof order === 'function' ? order : order === 'desc' ? createCompare(0) : createCompare(1);
|
|
518
521
|
var result = cmpFn(objCriteria[index], othCriteria[index]);
|
|
519
522
|
if (result) {
|
|
520
523
|
return result;
|
|
@@ -528,8 +531,8 @@
|
|
|
528
531
|
iteratees = (isArray(iteratees) ? iteratees : iteratees !== nativeUndefined ? [iteratees] : [identity]);
|
|
529
532
|
orders = (isArray(orders) ? orders : orders !== nativeUndefined ? [orders] : []);
|
|
530
533
|
var index = -1;
|
|
531
|
-
forEach(collection, function (item) {
|
|
532
|
-
var criteria = iteratees.map(function (iteratee) { return createIteratee(iteratee)(item); });
|
|
534
|
+
forEach(collection, function (item, key, arr) {
|
|
535
|
+
var criteria = iteratees.map(function (iteratee) { return createIteratee(iteratee)(item, key, arr); });
|
|
533
536
|
result.push({
|
|
534
537
|
criteria: criteria,
|
|
535
538
|
index: ++index,
|
|
@@ -552,15 +555,15 @@
|
|
|
552
555
|
if (predicate === void 0) { predicate = identity; }
|
|
553
556
|
var result = [[], []];
|
|
554
557
|
var internalIteratee = createIteratee(predicate);
|
|
555
|
-
forEach(collection, function (item) {
|
|
556
|
-
result[internalIteratee(item) ? 0 : 1].push(item);
|
|
558
|
+
forEach(collection, function (item, index, arr) {
|
|
559
|
+
result[internalIteratee(item, index, arr) ? 0 : 1].push(item);
|
|
557
560
|
});
|
|
558
561
|
return result;
|
|
559
562
|
};
|
|
560
563
|
|
|
561
564
|
function createReduce(dir) {
|
|
562
565
|
function reducer(collection, iteratee, memo, initial) {
|
|
563
|
-
var _keys = !isArrayLike(collection) &&
|
|
566
|
+
var _keys = !isArrayLike(collection) && allKeys(collection);
|
|
564
567
|
var len = (_keys || collection).length;
|
|
565
568
|
var i = dir > 0 ? 0 : len - 1;
|
|
566
569
|
if (!initial && len > 0) {
|
|
@@ -602,7 +605,7 @@
|
|
|
602
605
|
return value == null || value !== value ? defaultValue : value;
|
|
603
606
|
};
|
|
604
607
|
|
|
605
|
-
var VERSION = "1.
|
|
608
|
+
var VERSION = "1.9.1";
|
|
606
609
|
var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
|
|
607
610
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
608
611
|
function toSource(func) {
|
|
@@ -938,28 +941,6 @@
|
|
|
938
941
|
return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
|
|
939
942
|
}
|
|
940
943
|
|
|
941
|
-
function isPrototype(value) {
|
|
942
|
-
if (typeof value !== 'object') {
|
|
943
|
-
return false;
|
|
944
|
-
}
|
|
945
|
-
var Ctor = value.constructor;
|
|
946
|
-
var proto = typeof Ctor === 'function' ? Ctor.prototype : objectProto;
|
|
947
|
-
return value === proto;
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
function keys(value) {
|
|
951
|
-
if (!isPrototype(value)) {
|
|
952
|
-
return objectKeys(value);
|
|
953
|
-
}
|
|
954
|
-
var result = [];
|
|
955
|
-
for (var key in Object(value)) {
|
|
956
|
-
if (objectProtoHasOwnProperty.call(value, key) && key !== 'constructor') {
|
|
957
|
-
result.push(key);
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
return result;
|
|
961
|
-
}
|
|
962
|
-
|
|
963
944
|
function isEmpty(value) {
|
|
964
945
|
if (isNil(value)) {
|
|
965
946
|
return true;
|
|
@@ -969,7 +950,7 @@
|
|
|
969
950
|
return !value.size;
|
|
970
951
|
}
|
|
971
952
|
if (isObjectLike(value)) {
|
|
972
|
-
return !
|
|
953
|
+
return !allKeys(value).length;
|
|
973
954
|
}
|
|
974
955
|
if (isArrayLike(value)) {
|
|
975
956
|
return !value.length;
|
|
@@ -977,20 +958,6 @@
|
|
|
977
958
|
return true;
|
|
978
959
|
}
|
|
979
960
|
|
|
980
|
-
function getSymbols(object) {
|
|
981
|
-
if (!objectGetOwnPropertySymbols || object === null) {
|
|
982
|
-
return [];
|
|
983
|
-
}
|
|
984
|
-
return objectGetOwnPropertySymbols(object).filter(function (item) { return objectProtoPropertyIsEnumerable.call(object, item); });
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
function allKeys(object) {
|
|
988
|
-
if (!isObject(object)) {
|
|
989
|
-
return [];
|
|
990
|
-
}
|
|
991
|
-
return objectKeys(object).concat(getSymbols(object));
|
|
992
|
-
}
|
|
993
|
-
|
|
994
961
|
function isTypedArray(value) {
|
|
995
962
|
if (nodeIsTypedArray) {
|
|
996
963
|
return nodeIsTypedArray(value);
|
|
@@ -1274,10 +1241,6 @@
|
|
|
1274
1241
|
return baseIsMatch(object, source, customizer, strictCheck, nativeUndefined, nativeUndefined);
|
|
1275
1242
|
}
|
|
1276
1243
|
|
|
1277
|
-
function isNumber(value) {
|
|
1278
|
-
return typeof value === 'number' || getTag(value) === numberTag;
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
1244
|
function isNaN(value) {
|
|
1282
1245
|
return isNumber(value) && root.isNaN(value);
|
|
1283
1246
|
}
|
|
@@ -1364,8 +1327,8 @@
|
|
|
1364
1327
|
}
|
|
1365
1328
|
var result, computed;
|
|
1366
1329
|
var internalIteratee = createIteratee(iteratee);
|
|
1367
|
-
array.forEach(function (value) {
|
|
1368
|
-
var current = internalIteratee(value);
|
|
1330
|
+
array.forEach(function (value, index) {
|
|
1331
|
+
var current = internalIteratee(value, index, array);
|
|
1369
1332
|
if (current != null && (computed === nativeUndefined ? current === current && !isSymbol(current) : comparator(current, computed))) {
|
|
1370
1333
|
computed = current;
|
|
1371
1334
|
result = value;
|
|
@@ -1374,13 +1337,13 @@
|
|
|
1374
1337
|
return result;
|
|
1375
1338
|
}
|
|
1376
1339
|
|
|
1377
|
-
function
|
|
1340
|
+
var max = function (array, iteratee) {
|
|
1378
1341
|
return createExtremum(array, baseGt, iteratee);
|
|
1379
|
-
}
|
|
1342
|
+
};
|
|
1380
1343
|
|
|
1381
|
-
function
|
|
1344
|
+
var min = function (array, iteratee) {
|
|
1382
1345
|
return createExtremum(array, baseLt, iteratee);
|
|
1383
|
-
}
|
|
1346
|
+
};
|
|
1384
1347
|
|
|
1385
1348
|
function round(number, precision) {
|
|
1386
1349
|
return decimalAdjust('round', number, precision);
|
|
@@ -1458,7 +1421,7 @@
|
|
|
1458
1421
|
|
|
1459
1422
|
function invert(object, predicate) {
|
|
1460
1423
|
if (predicate === void 0) { predicate = stubTrue; }
|
|
1461
|
-
var _keys =
|
|
1424
|
+
var _keys = allKeys(object);
|
|
1462
1425
|
var result = {};
|
|
1463
1426
|
_keys.forEach(function (key) {
|
|
1464
1427
|
var value = object[key];
|
|
@@ -1473,6 +1436,13 @@
|
|
|
1473
1436
|
return result;
|
|
1474
1437
|
}
|
|
1475
1438
|
|
|
1439
|
+
function keys(object) {
|
|
1440
|
+
if (!isObject(object)) {
|
|
1441
|
+
return [];
|
|
1442
|
+
}
|
|
1443
|
+
return objectKeys(object);
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1476
1446
|
function keysIn(object) {
|
|
1477
1447
|
if (!isObject(object)) {
|
|
1478
1448
|
return [];
|
|
@@ -1523,7 +1493,7 @@
|
|
|
1523
1493
|
return obj;
|
|
1524
1494
|
}
|
|
1525
1495
|
function merge(object, source, customizer, getKeys) {
|
|
1526
|
-
if (getKeys === void 0) { getKeys =
|
|
1496
|
+
if (getKeys === void 0) { getKeys = allKeys; }
|
|
1527
1497
|
return baseMerge(object, source, getKeys, customizer);
|
|
1528
1498
|
}
|
|
1529
1499
|
|
|
@@ -1550,9 +1520,6 @@
|
|
|
1550
1520
|
function pickBy(object, predicate) {
|
|
1551
1521
|
if (predicate === void 0) { predicate = stubFlase; }
|
|
1552
1522
|
var result = {};
|
|
1553
|
-
if (isNil(object)) {
|
|
1554
|
-
return result;
|
|
1555
|
-
}
|
|
1556
1523
|
var keys = allKeysIn(object);
|
|
1557
1524
|
keys.forEach(function (key) {
|
|
1558
1525
|
if (predicate(object[key], key)) {
|
|
@@ -1570,6 +1537,9 @@
|
|
|
1570
1537
|
var pick = function (object, fields) {
|
|
1571
1538
|
if (fields === void 0) { fields = []; }
|
|
1572
1539
|
var result = {};
|
|
1540
|
+
if (!isObject(object)) {
|
|
1541
|
+
return result;
|
|
1542
|
+
}
|
|
1573
1543
|
var fieldArr = castArray(fields);
|
|
1574
1544
|
fieldArr.forEach(function (field) {
|
|
1575
1545
|
if (field in object) {
|
|
@@ -1882,7 +1852,7 @@
|
|
|
1882
1852
|
exports.isWeakSet = isWeakSet;
|
|
1883
1853
|
exports.kebabCase = kebabCase;
|
|
1884
1854
|
exports.keyBy = keyBy;
|
|
1885
|
-
exports.keys = keys
|
|
1855
|
+
exports.keys = keys;
|
|
1886
1856
|
exports.keysIn = keysIn;
|
|
1887
1857
|
exports.lowerCase = lowerCase;
|
|
1888
1858
|
exports.lowerFirst = lowerFirst;
|