es-toolkit 1.27.0 → 1.28.0-dev.908
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/CHANGELOG.md +14 -0
- package/dist/_chunk/{isWeakSet-D8h8bS.js → isWeakSet-CvIdTA.js} +5 -0
- package/dist/_chunk/{upperFirst-DK_rTF.js → upperFirst-CorAVn.js} +1 -0
- package/dist/array/differenceBy.d.mts +10 -3
- package/dist/array/differenceBy.d.ts +10 -3
- package/dist/array/differenceWith.d.mts +11 -4
- package/dist/array/differenceWith.d.ts +11 -4
- package/dist/array/flatMap.d.mts +1 -1
- package/dist/array/flatMap.d.ts +1 -1
- package/dist/array/intersectionBy.d.mts +16 -5
- package/dist/array/intersectionBy.d.ts +16 -5
- package/dist/array/intersectionWith.d.mts +16 -4
- package/dist/array/intersectionWith.d.ts +16 -4
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/dropRightWhile.d.mts +2 -2
- package/dist/compat/array/dropRightWhile.d.ts +2 -2
- package/dist/compat/array/dropRightWhile.mjs +2 -0
- package/dist/compat/array/dropWhile.d.mts +2 -2
- package/dist/compat/array/dropWhile.d.ts +2 -2
- package/dist/compat/array/dropWhile.mjs +2 -0
- package/dist/compat/array/every.d.mts +6 -6
- package/dist/compat/array/every.d.ts +6 -6
- package/dist/compat/array/every.mjs +2 -0
- package/dist/compat/array/filter.d.mts +4 -4
- package/dist/compat/array/filter.d.ts +4 -4
- package/dist/compat/array/filter.mjs +2 -0
- package/dist/compat/array/find.d.mts +6 -6
- package/dist/compat/array/find.d.ts +6 -6
- package/dist/compat/array/find.mjs +2 -0
- package/dist/compat/array/findIndex.d.mts +3 -3
- package/dist/compat/array/findIndex.d.ts +3 -3
- package/dist/compat/array/findIndex.mjs +2 -0
- package/dist/compat/array/findLastIndex.d.mts +3 -3
- package/dist/compat/array/findLastIndex.d.ts +3 -3
- package/dist/compat/array/findLastIndex.mjs +2 -0
- package/dist/compat/array/some.d.mts +5 -5
- package/dist/compat/array/some.d.ts +5 -5
- package/dist/compat/array/some.mjs +2 -0
- package/dist/compat/array/uniqBy.d.mts +34 -13
- package/dist/compat/array/uniqBy.d.ts +34 -13
- package/dist/compat/array/uniqBy.mjs +3 -16
- package/dist/compat/function/debounce.d.mts +7 -5
- package/dist/compat/function/debounce.d.ts +7 -5
- package/dist/compat/function/throttle.d.mts +3 -4
- package/dist/compat/function/throttle.d.ts +3 -4
- package/dist/compat/function/throttle.mjs +6 -1
- package/dist/compat/index.d.mts +12 -2
- package/dist/compat/index.d.ts +12 -2
- package/dist/compat/index.js +179 -48
- package/dist/compat/index.mjs +10 -1
- package/dist/compat/math/add.d.mts +18 -0
- package/dist/compat/math/add.d.ts +18 -0
- package/dist/compat/math/add.mjs +5 -0
- package/dist/compat/object/assignIn.d.mts +103 -0
- package/dist/compat/object/assignIn.d.ts +103 -0
- package/dist/compat/object/assignIn.mjs +20 -0
- package/dist/compat/object/keysIn.d.mts +26 -0
- package/dist/compat/object/keysIn.d.ts +26 -0
- package/dist/compat/object/keysIn.mjs +53 -0
- package/dist/compat/predicate/isElement.d.mts +13 -0
- package/dist/compat/predicate/isElement.d.ts +13 -0
- package/dist/compat/predicate/isElement.mjs +8 -0
- package/dist/compat/string/toUpper.d.mts +20 -0
- package/dist/compat/string/toUpper.d.ts +20 -0
- package/dist/compat/string/toUpper.mjs +7 -0
- package/dist/compat/string/trim.mjs +1 -1
- package/dist/compat/string/trimEnd.mjs +1 -1
- package/dist/compat/string/trimStart.mjs +1 -1
- package/dist/compat/string/words.d.mts +15 -0
- package/dist/compat/string/words.d.ts +15 -0
- package/dist/compat/string/words.mjs +10 -0
- package/dist/compat/util/gt.d.mts +15 -0
- package/dist/compat/util/gt.d.ts +15 -0
- package/dist/compat/util/gt.mjs +10 -0
- package/dist/compat/util/gte.d.mts +15 -0
- package/dist/compat/util/gte.d.ts +15 -0
- package/dist/compat/util/gte.mjs +10 -0
- package/dist/compat/util/iteratee.d.mts +1 -1
- package/dist/compat/util/iteratee.d.ts +1 -1
- package/dist/compat/util/toArray.d.mts +15 -0
- package/dist/compat/util/toArray.d.ts +15 -0
- package/dist/compat/util/toArray.mjs +20 -0
- package/dist/function/debounce.d.mts +24 -22
- package/dist/function/debounce.d.ts +24 -22
- package/dist/function/index.d.mts +2 -2
- package/dist/function/index.d.ts +2 -2
- package/dist/function/partial.d.mts +533 -15
- package/dist/function/partial.d.ts +533 -15
- package/dist/function/partialRight.d.mts +610 -15
- package/dist/function/partialRight.d.ts +610 -15
- package/dist/function/throttle.d.mts +7 -5
- package/dist/function/throttle.d.ts +7 -5
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/index.mjs +1 -0
- package/dist/predicate/index.d.mts +1 -0
- package/dist/predicate/index.d.ts +1 -0
- package/dist/predicate/index.js +2 -1
- package/dist/predicate/index.mjs +1 -0
- package/dist/predicate/isBuffer.d.mts +21 -0
- package/dist/predicate/isBuffer.d.ts +21 -0
- package/dist/predicate/isBuffer.mjs +5 -0
- package/dist/string/index.js +1 -1
- package/package.json +1 -1
package/dist/compat/index.js
CHANGED
|
@@ -10,8 +10,8 @@ const rangeRight = require('../_chunk/rangeRight-w3WrXN.js');
|
|
|
10
10
|
const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
11
11
|
const toMerged = require('../_chunk/toMerged-CPY8Ug.js');
|
|
12
12
|
const isPlainObject$1 = require('../_chunk/isPlainObject-octpoD.js');
|
|
13
|
-
const isWeakSet$1 = require('../_chunk/isWeakSet-
|
|
14
|
-
const upperFirst = require('../_chunk/upperFirst-
|
|
13
|
+
const isWeakSet$1 = require('../_chunk/isWeakSet-CvIdTA.js');
|
|
14
|
+
const upperFirst = require('../_chunk/upperFirst-CorAVn.js');
|
|
15
15
|
const util_index = require('../util/index.js');
|
|
16
16
|
|
|
17
17
|
function castArray(value) {
|
|
@@ -21,7 +21,7 @@ function castArray(value) {
|
|
|
21
21
|
return Array.isArray(value) ? value : [value];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function toArray(value) {
|
|
24
|
+
function toArray$1(value) {
|
|
25
25
|
return Array.isArray(value) ? value : Array.from(value);
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -34,7 +34,7 @@ function chunk(arr, size = 1) {
|
|
|
34
34
|
if (size === 0 || !isArrayLike(arr)) {
|
|
35
35
|
return [];
|
|
36
36
|
}
|
|
37
|
-
return zipWith.chunk(toArray(arr), size);
|
|
37
|
+
return zipWith.chunk(toArray$1(arr), size);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function compact(arr) {
|
|
@@ -56,7 +56,7 @@ function difference(arr, ...values) {
|
|
|
56
56
|
if (!isArrayLikeObject(arr)) {
|
|
57
57
|
return [];
|
|
58
58
|
}
|
|
59
|
-
const arr1 = toArray(arr);
|
|
59
|
+
const arr1 = toArray$1(arr);
|
|
60
60
|
const arr2 = [];
|
|
61
61
|
for (let i = 0; i < values.length; i++) {
|
|
62
62
|
const value = values[i];
|
|
@@ -71,7 +71,7 @@ function last(array) {
|
|
|
71
71
|
if (!isArrayLike(array)) {
|
|
72
72
|
return undefined;
|
|
73
73
|
}
|
|
74
|
-
return zipWith.last(toArray(array));
|
|
74
|
+
return zipWith.last(toArray$1(array));
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
function flattenArrayLike(values) {
|
|
@@ -520,7 +520,7 @@ function drop(collection, itemsCount = 1, guard) {
|
|
|
520
520
|
return [];
|
|
521
521
|
}
|
|
522
522
|
itemsCount = guard ? 1 : toInteger(itemsCount);
|
|
523
|
-
return zipWith.drop(toArray(collection), itemsCount);
|
|
523
|
+
return zipWith.drop(toArray$1(collection), itemsCount);
|
|
524
524
|
}
|
|
525
525
|
|
|
526
526
|
function dropRight(collection, itemsCount = 1, guard) {
|
|
@@ -528,7 +528,7 @@ function dropRight(collection, itemsCount = 1, guard) {
|
|
|
528
528
|
return [];
|
|
529
529
|
}
|
|
530
530
|
itemsCount = guard ? 1 : toInteger(itemsCount);
|
|
531
|
-
return zipWith.dropRight(toArray(collection), itemsCount);
|
|
531
|
+
return zipWith.dropRight(toArray$1(collection), itemsCount);
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
function dropRightWhile(arr, predicate) {
|
|
@@ -552,6 +552,8 @@ function dropRightWhileImpl(arr, predicate) {
|
|
|
552
552
|
return zipWith.dropRightWhile(arr, matches(predicate));
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
|
+
case 'symbol':
|
|
556
|
+
case 'number':
|
|
555
557
|
case 'string': {
|
|
556
558
|
return zipWith.dropRightWhile(arr, property(predicate));
|
|
557
559
|
}
|
|
@@ -562,7 +564,7 @@ function dropWhile(arr, predicate) {
|
|
|
562
564
|
if (!isArrayLike(arr)) {
|
|
563
565
|
return [];
|
|
564
566
|
}
|
|
565
|
-
return dropWhileImpl(toArray(arr), predicate);
|
|
567
|
+
return dropWhileImpl(toArray$1(arr), predicate);
|
|
566
568
|
}
|
|
567
569
|
function dropWhileImpl(arr, predicate) {
|
|
568
570
|
switch (typeof predicate) {
|
|
@@ -579,6 +581,8 @@ function dropWhileImpl(arr, predicate) {
|
|
|
579
581
|
return zipWith.dropWhile(arr, matches(predicate));
|
|
580
582
|
}
|
|
581
583
|
}
|
|
584
|
+
case 'number':
|
|
585
|
+
case 'symbol':
|
|
582
586
|
case 'string': {
|
|
583
587
|
return zipWith.dropWhile(arr, property(predicate));
|
|
584
588
|
}
|
|
@@ -632,6 +636,8 @@ function every(source, doesMatch, guard) {
|
|
|
632
636
|
return values.every(matches(doesMatch));
|
|
633
637
|
}
|
|
634
638
|
}
|
|
639
|
+
case 'symbol':
|
|
640
|
+
case 'number':
|
|
635
641
|
case 'string': {
|
|
636
642
|
return values.every(property(doesMatch));
|
|
637
643
|
}
|
|
@@ -693,6 +699,8 @@ function filter(source, predicate) {
|
|
|
693
699
|
? collection.filter(matchesProperty(predicate[0], predicate[1]))
|
|
694
700
|
: collection.filter(matches(predicate));
|
|
695
701
|
}
|
|
702
|
+
case 'symbol':
|
|
703
|
+
case 'number':
|
|
696
704
|
case 'string': {
|
|
697
705
|
return collection.filter(property(predicate));
|
|
698
706
|
}
|
|
@@ -729,6 +737,8 @@ function find(source, doesMatch) {
|
|
|
729
737
|
return values.find(matches(doesMatch));
|
|
730
738
|
}
|
|
731
739
|
}
|
|
740
|
+
case 'symbol':
|
|
741
|
+
case 'number':
|
|
732
742
|
case 'string': {
|
|
733
743
|
return values.find(property(doesMatch));
|
|
734
744
|
}
|
|
@@ -760,6 +770,8 @@ function findIndex(arr, doesMatch, fromIndex = 0) {
|
|
|
760
770
|
}
|
|
761
771
|
break;
|
|
762
772
|
}
|
|
773
|
+
case 'number':
|
|
774
|
+
case 'symbol':
|
|
763
775
|
case 'string': {
|
|
764
776
|
index = subArray.findIndex(property(doesMatch));
|
|
765
777
|
}
|
|
@@ -777,7 +789,7 @@ function findLastIndex(arr, doesMatch, fromIndex = arr ? arr.length - 1 : 0) {
|
|
|
777
789
|
else {
|
|
778
790
|
fromIndex = Math.min(fromIndex, arr.length - 1);
|
|
779
791
|
}
|
|
780
|
-
const subArray = toArray(arr).slice(0, fromIndex + 1);
|
|
792
|
+
const subArray = toArray$1(arr).slice(0, fromIndex + 1);
|
|
781
793
|
switch (typeof doesMatch) {
|
|
782
794
|
case 'function': {
|
|
783
795
|
return subArray.findLastIndex(doesMatch);
|
|
@@ -792,6 +804,8 @@ function findLastIndex(arr, doesMatch, fromIndex = arr ? arr.length - 1 : 0) {
|
|
|
792
804
|
return subArray.findLastIndex(matches(doesMatch));
|
|
793
805
|
}
|
|
794
806
|
}
|
|
807
|
+
case 'number':
|
|
808
|
+
case 'symbol':
|
|
795
809
|
case 'string': {
|
|
796
810
|
return subArray.findLastIndex(property(doesMatch));
|
|
797
811
|
}
|
|
@@ -855,7 +869,7 @@ function head(arr) {
|
|
|
855
869
|
if (!isArrayLike(arr)) {
|
|
856
870
|
return undefined;
|
|
857
871
|
}
|
|
858
|
-
return zipWith.head(toArray(arr));
|
|
872
|
+
return zipWith.head(toArray$1(arr));
|
|
859
873
|
}
|
|
860
874
|
|
|
861
875
|
function includes(source, target, fromIndex, guard) {
|
|
@@ -1091,7 +1105,7 @@ function sample(collection) {
|
|
|
1091
1105
|
return undefined;
|
|
1092
1106
|
}
|
|
1093
1107
|
if (isArrayLike(collection)) {
|
|
1094
|
-
return zipWith.sample(toArray(collection));
|
|
1108
|
+
return zipWith.sample(toArray$1(collection));
|
|
1095
1109
|
}
|
|
1096
1110
|
return zipWith.sample(Object.values(collection));
|
|
1097
1111
|
}
|
|
@@ -1176,6 +1190,8 @@ function some(source, predicate, guard) {
|
|
|
1176
1190
|
return values.some(matches(predicate));
|
|
1177
1191
|
}
|
|
1178
1192
|
}
|
|
1193
|
+
case 'number':
|
|
1194
|
+
case 'symbol':
|
|
1179
1195
|
case 'string': {
|
|
1180
1196
|
return values.some(property(predicate));
|
|
1181
1197
|
}
|
|
@@ -1197,7 +1213,7 @@ function tail(arr) {
|
|
|
1197
1213
|
if (!isArrayLike(arr)) {
|
|
1198
1214
|
return [];
|
|
1199
1215
|
}
|
|
1200
|
-
return zipWith.tail(toArray(arr));
|
|
1216
|
+
return zipWith.tail(toArray$1(arr));
|
|
1201
1217
|
}
|
|
1202
1218
|
|
|
1203
1219
|
function take(arr, count = 1, guard) {
|
|
@@ -1205,7 +1221,7 @@ function take(arr, count = 1, guard) {
|
|
|
1205
1221
|
if (count < 1 || !isArrayLike(arr)) {
|
|
1206
1222
|
return [];
|
|
1207
1223
|
}
|
|
1208
|
-
return zipWith.take(toArray(arr), count);
|
|
1224
|
+
return zipWith.take(toArray$1(arr), count);
|
|
1209
1225
|
}
|
|
1210
1226
|
|
|
1211
1227
|
function takeRight(arr, count = 1, guard) {
|
|
@@ -1213,7 +1229,7 @@ function takeRight(arr, count = 1, guard) {
|
|
|
1213
1229
|
if (count <= 0 || !isArrayLike(arr)) {
|
|
1214
1230
|
return [];
|
|
1215
1231
|
}
|
|
1216
|
-
return zipWith.takeRight(toArray(arr), count);
|
|
1232
|
+
return zipWith.takeRight(toArray$1(arr), count);
|
|
1217
1233
|
}
|
|
1218
1234
|
|
|
1219
1235
|
function union(...arrays) {
|
|
@@ -1229,21 +1245,11 @@ function uniq(arr) {
|
|
|
1229
1245
|
return zipWith.uniq(Array.from(arr));
|
|
1230
1246
|
}
|
|
1231
1247
|
|
|
1232
|
-
function uniqBy(
|
|
1233
|
-
if (!isArrayLikeObject(
|
|
1248
|
+
function uniqBy(array, iteratee$1) {
|
|
1249
|
+
if (!isArrayLikeObject(array)) {
|
|
1234
1250
|
return [];
|
|
1235
1251
|
}
|
|
1236
|
-
|
|
1237
|
-
if (iteratee$1 === undefined) {
|
|
1238
|
-
return Array.from(arr);
|
|
1239
|
-
}
|
|
1240
|
-
const validArrays = values.slice(0, -1).filter(isArrayLikeObject);
|
|
1241
|
-
const flattenedArrays = flatten(validArrays);
|
|
1242
|
-
const allValues = [...Array.from(arr), ...flattenedArrays];
|
|
1243
|
-
if (isArrayLikeObject(iteratee$1)) {
|
|
1244
|
-
return zipWith.uniq(allValues);
|
|
1245
|
-
}
|
|
1246
|
-
return zipWith.uniqBy(allValues, iteratee(iteratee$1));
|
|
1252
|
+
return zipWith.uniqBy(Array.from(array), iteratee(iteratee$1));
|
|
1247
1253
|
}
|
|
1248
1254
|
|
|
1249
1255
|
function unzip(array) {
|
|
@@ -1624,7 +1630,16 @@ function throttle(func, throttleMs = 0, options = {}) {
|
|
|
1624
1630
|
options = {};
|
|
1625
1631
|
}
|
|
1626
1632
|
const { leading = true, trailing = true, signal } = options;
|
|
1627
|
-
return debounce(func, throttleMs, {
|
|
1633
|
+
return debounce(func, throttleMs, {
|
|
1634
|
+
leading,
|
|
1635
|
+
trailing,
|
|
1636
|
+
signal,
|
|
1637
|
+
maxWait: throttleMs,
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
function add(value, other) {
|
|
1642
|
+
return value + other;
|
|
1628
1643
|
}
|
|
1629
1644
|
|
|
1630
1645
|
function decimalAdjust(type, number, precision = 0) {
|
|
@@ -1811,6 +1826,90 @@ function sum(array) {
|
|
|
1811
1826
|
return sumBy(array);
|
|
1812
1827
|
}
|
|
1813
1828
|
|
|
1829
|
+
function isPrototype(value) {
|
|
1830
|
+
const constructor = value.constructor;
|
|
1831
|
+
const prototype = typeof constructor === 'function' ? constructor.prototype : Object.prototype;
|
|
1832
|
+
return value === prototype;
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
function isTypedArray(x) {
|
|
1836
|
+
return isPlainObject$1.isTypedArray(x);
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
function times(n, getValue) {
|
|
1840
|
+
n = toInteger(n);
|
|
1841
|
+
if (n < 1 || !Number.isSafeInteger(n)) {
|
|
1842
|
+
return [];
|
|
1843
|
+
}
|
|
1844
|
+
const result = new Array(n);
|
|
1845
|
+
for (let i = 0; i < n; i++) {
|
|
1846
|
+
result[i] = typeof getValue === 'function' ? getValue(i) : i;
|
|
1847
|
+
}
|
|
1848
|
+
return result;
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
function keysIn(object) {
|
|
1852
|
+
if (object == null) {
|
|
1853
|
+
return [];
|
|
1854
|
+
}
|
|
1855
|
+
switch (typeof object) {
|
|
1856
|
+
case 'object':
|
|
1857
|
+
case 'function': {
|
|
1858
|
+
if (isArrayLike(object)) {
|
|
1859
|
+
return arrayLikeKeysIn(object);
|
|
1860
|
+
}
|
|
1861
|
+
if (isPrototype(object)) {
|
|
1862
|
+
return prototypeKeysIn(object);
|
|
1863
|
+
}
|
|
1864
|
+
return keysInImpl(object);
|
|
1865
|
+
}
|
|
1866
|
+
default: {
|
|
1867
|
+
return keysInImpl(Object(object));
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
function keysInImpl(object) {
|
|
1872
|
+
const result = [];
|
|
1873
|
+
for (const key in object) {
|
|
1874
|
+
result.push(key);
|
|
1875
|
+
}
|
|
1876
|
+
return result;
|
|
1877
|
+
}
|
|
1878
|
+
function prototypeKeysIn(object) {
|
|
1879
|
+
const keys = keysInImpl(object);
|
|
1880
|
+
return keys.filter(key => key !== 'constructor');
|
|
1881
|
+
}
|
|
1882
|
+
function arrayLikeKeysIn(object) {
|
|
1883
|
+
const indices = times(object.length, index => `${index}`);
|
|
1884
|
+
const filteredKeys = new Set(indices);
|
|
1885
|
+
if (isWeakSet$1.isBuffer(object)) {
|
|
1886
|
+
filteredKeys.add('offset');
|
|
1887
|
+
filteredKeys.add('parent');
|
|
1888
|
+
}
|
|
1889
|
+
if (isTypedArray(object)) {
|
|
1890
|
+
filteredKeys.add('buffer');
|
|
1891
|
+
filteredKeys.add('byteLength');
|
|
1892
|
+
filteredKeys.add('byteOffset');
|
|
1893
|
+
}
|
|
1894
|
+
return [...indices, ...keysInImpl(object).filter(key => !filteredKeys.has(key))];
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
function assignIn(object, ...sources) {
|
|
1898
|
+
for (let i = 0; i < sources.length; i++) {
|
|
1899
|
+
assignInImpl(object, sources[i]);
|
|
1900
|
+
}
|
|
1901
|
+
return object;
|
|
1902
|
+
}
|
|
1903
|
+
function assignInImpl(object, source) {
|
|
1904
|
+
const keys = keysIn(source);
|
|
1905
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1906
|
+
const key = keys[i];
|
|
1907
|
+
if (!isWeakSet$1.eq(object[key], source[key])) {
|
|
1908
|
+
object[key] = source[key];
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1814
1913
|
function defaults(object, ...sources) {
|
|
1815
1914
|
object = Object(object);
|
|
1816
1915
|
const objectProto = Object.prototype;
|
|
@@ -1921,10 +2020,6 @@ function isPlainObject(object) {
|
|
|
1921
2020
|
return Object.getPrototypeOf(object) === proto;
|
|
1922
2021
|
}
|
|
1923
2022
|
|
|
1924
|
-
function isTypedArray(x) {
|
|
1925
|
-
return isPlainObject$1.isTypedArray(x);
|
|
1926
|
-
}
|
|
1927
|
-
|
|
1928
2023
|
function mergeWith(object, ...otherArgs) {
|
|
1929
2024
|
const sources = otherArgs.slice(0, -1);
|
|
1930
2025
|
const merge = otherArgs[otherArgs.length - 1];
|
|
@@ -2179,10 +2274,8 @@ function isDate(value) {
|
|
|
2179
2274
|
return isWeakSet$1.isDate(value);
|
|
2180
2275
|
}
|
|
2181
2276
|
|
|
2182
|
-
function
|
|
2183
|
-
|
|
2184
|
-
const prototype = typeof constructor === 'function' ? constructor.prototype : Object.prototype;
|
|
2185
|
-
return value === prototype;
|
|
2277
|
+
function isElement(value) {
|
|
2278
|
+
return toMerged.isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
|
|
2186
2279
|
}
|
|
2187
2280
|
|
|
2188
2281
|
function isEmpty(value) {
|
|
@@ -2444,6 +2537,10 @@ function template(string, options, guard) {
|
|
|
2444
2537
|
return result;
|
|
2445
2538
|
}
|
|
2446
2539
|
|
|
2540
|
+
function toUpper(value) {
|
|
2541
|
+
return toString(value).toUpperCase();
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2447
2544
|
function trim(str, chars, guard) {
|
|
2448
2545
|
if (str == null) {
|
|
2449
2546
|
return '';
|
|
@@ -2457,7 +2554,7 @@ function trim(str, chars, guard) {
|
|
|
2457
2554
|
}
|
|
2458
2555
|
case 'object': {
|
|
2459
2556
|
if (Array.isArray(chars)) {
|
|
2460
|
-
return upperFirst.trim(str, chars.
|
|
2557
|
+
return upperFirst.trim(str, chars.flatMap(x => x.toString().split('')));
|
|
2461
2558
|
}
|
|
2462
2559
|
else {
|
|
2463
2560
|
return upperFirst.trim(str, chars.toString().split(''));
|
|
@@ -2479,7 +2576,7 @@ function trimEnd(str, chars, guard) {
|
|
|
2479
2576
|
}
|
|
2480
2577
|
case 'object': {
|
|
2481
2578
|
if (Array.isArray(chars)) {
|
|
2482
|
-
return upperFirst.trimEnd(str, chars.
|
|
2579
|
+
return upperFirst.trimEnd(str, chars.flatMap(x => x.toString().split('')));
|
|
2483
2580
|
}
|
|
2484
2581
|
else {
|
|
2485
2582
|
return upperFirst.trimEnd(str, chars.toString().split(''));
|
|
@@ -2501,7 +2598,7 @@ function trimStart(str, chars, guard) {
|
|
|
2501
2598
|
}
|
|
2502
2599
|
case 'object': {
|
|
2503
2600
|
if (Array.isArray(chars)) {
|
|
2504
|
-
return upperFirst.trimStart(str, chars.
|
|
2601
|
+
return upperFirst.trimStart(str, chars.flatMap(x => x.toString().split('')));
|
|
2505
2602
|
}
|
|
2506
2603
|
else {
|
|
2507
2604
|
return upperFirst.trimStart(str, chars.toString().split(''));
|
|
@@ -2514,6 +2611,12 @@ function upperCase(str) {
|
|
|
2514
2611
|
return upperFirst.upperCase(normalizeForCase(str));
|
|
2515
2612
|
}
|
|
2516
2613
|
|
|
2614
|
+
function words(str, pattern = upperFirst.CASE_SPLIT_PATTERN) {
|
|
2615
|
+
const input = toString(str);
|
|
2616
|
+
const words = Array.from(input.match(pattern) ?? []);
|
|
2617
|
+
return words.filter(x => x !== '');
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2517
2620
|
function constant(value) {
|
|
2518
2621
|
return () => value;
|
|
2519
2622
|
}
|
|
@@ -2525,16 +2628,34 @@ function defaultTo(value, defaultValue) {
|
|
|
2525
2628
|
return value;
|
|
2526
2629
|
}
|
|
2527
2630
|
|
|
2528
|
-
function
|
|
2529
|
-
|
|
2530
|
-
|
|
2631
|
+
function gt(value, other) {
|
|
2632
|
+
if (typeof value === 'string' && typeof other === 'string') {
|
|
2633
|
+
return value > other;
|
|
2634
|
+
}
|
|
2635
|
+
return toNumber(value) > toNumber(other);
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
function gte(value, other) {
|
|
2639
|
+
if (typeof value === 'string' && typeof other === 'string') {
|
|
2640
|
+
return value >= other;
|
|
2641
|
+
}
|
|
2642
|
+
return toNumber(value) >= toNumber(other);
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
function toArray(value) {
|
|
2646
|
+
if (value == null) {
|
|
2531
2647
|
return [];
|
|
2532
2648
|
}
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
result[i] = typeof getValue === 'function' ? getValue(i) : i;
|
|
2649
|
+
if (isArrayLike(value) || isMap(value)) {
|
|
2650
|
+
return Array.from(value);
|
|
2536
2651
|
}
|
|
2537
|
-
|
|
2652
|
+
if (typeof value === 'string') {
|
|
2653
|
+
return value.split('');
|
|
2654
|
+
}
|
|
2655
|
+
if (typeof value === 'object') {
|
|
2656
|
+
return Object.values(value);
|
|
2657
|
+
}
|
|
2658
|
+
return [];
|
|
2538
2659
|
}
|
|
2539
2660
|
|
|
2540
2661
|
const MAX_ARRAY_LENGTH = 4_294_967_295;
|
|
@@ -2624,6 +2745,7 @@ exports.toMerged = toMerged.toMerged;
|
|
|
2624
2745
|
exports.isPrimitive = isPlainObject$1.isPrimitive;
|
|
2625
2746
|
exports.eq = isWeakSet$1.eq;
|
|
2626
2747
|
exports.isBlob = isWeakSet$1.isBlob;
|
|
2748
|
+
exports.isBuffer = isWeakSet$1.isBuffer;
|
|
2627
2749
|
exports.isEqual = isWeakSet$1.isEqual;
|
|
2628
2750
|
exports.isFile = isWeakSet$1.isFile;
|
|
2629
2751
|
exports.isFunction = isWeakSet$1.isFunction;
|
|
@@ -2642,9 +2764,10 @@ exports.lowerFirst = upperFirst.lowerFirst;
|
|
|
2642
2764
|
exports.pascalCase = upperFirst.pascalCase;
|
|
2643
2765
|
exports.unescape = upperFirst.unescape;
|
|
2644
2766
|
exports.upperFirst = upperFirst.upperFirst;
|
|
2645
|
-
exports.words = upperFirst.words;
|
|
2646
2767
|
exports.invariant = util_index.invariant;
|
|
2768
|
+
exports.add = add;
|
|
2647
2769
|
exports.ary = ary;
|
|
2770
|
+
exports.assignIn = assignIn;
|
|
2648
2771
|
exports.attempt = attempt;
|
|
2649
2772
|
exports.before = before;
|
|
2650
2773
|
exports.bind = bind;
|
|
@@ -2676,6 +2799,7 @@ exports.each = forEach;
|
|
|
2676
2799
|
exports.endsWith = endsWith;
|
|
2677
2800
|
exports.escape = escape;
|
|
2678
2801
|
exports.every = every;
|
|
2802
|
+
exports.extend = assignIn;
|
|
2679
2803
|
exports.fill = fill;
|
|
2680
2804
|
exports.filter = filter;
|
|
2681
2805
|
exports.find = find;
|
|
@@ -2692,6 +2816,8 @@ exports.flowRight = flowRight;
|
|
|
2692
2816
|
exports.forEach = forEach;
|
|
2693
2817
|
exports.fromPairs = fromPairs;
|
|
2694
2818
|
exports.get = get;
|
|
2819
|
+
exports.gt = gt;
|
|
2820
|
+
exports.gte = gte;
|
|
2695
2821
|
exports.has = has;
|
|
2696
2822
|
exports.head = head;
|
|
2697
2823
|
exports.inRange = inRange;
|
|
@@ -2707,6 +2833,7 @@ exports.isArrayLike = isArrayLike;
|
|
|
2707
2833
|
exports.isArrayLikeObject = isArrayLikeObject;
|
|
2708
2834
|
exports.isBoolean = isBoolean;
|
|
2709
2835
|
exports.isDate = isDate;
|
|
2836
|
+
exports.isElement = isElement;
|
|
2710
2837
|
exports.isEmpty = isEmpty;
|
|
2711
2838
|
exports.isEqualWith = isEqualWith;
|
|
2712
2839
|
exports.isError = isError;
|
|
@@ -2730,6 +2857,7 @@ exports.isWeakSet = isWeakSet;
|
|
|
2730
2857
|
exports.iteratee = iteratee;
|
|
2731
2858
|
exports.join = join;
|
|
2732
2859
|
exports.kebabCase = kebabCase;
|
|
2860
|
+
exports.keysIn = keysIn;
|
|
2733
2861
|
exports.last = last;
|
|
2734
2862
|
exports.lowerCase = lowerCase;
|
|
2735
2863
|
exports.mapKeys = mapKeys;
|
|
@@ -2773,6 +2901,7 @@ exports.template = template;
|
|
|
2773
2901
|
exports.templateSettings = templateSettings;
|
|
2774
2902
|
exports.throttle = throttle;
|
|
2775
2903
|
exports.times = times;
|
|
2904
|
+
exports.toArray = toArray;
|
|
2776
2905
|
exports.toDefaulted = toDefaulted;
|
|
2777
2906
|
exports.toFinite = toFinite;
|
|
2778
2907
|
exports.toInteger = toInteger;
|
|
@@ -2781,6 +2910,7 @@ exports.toNumber = toNumber;
|
|
|
2781
2910
|
exports.toPath = toPath;
|
|
2782
2911
|
exports.toSafeInteger = toSafeInteger;
|
|
2783
2912
|
exports.toString = toString;
|
|
2913
|
+
exports.toUpper = toUpper;
|
|
2784
2914
|
exports.trim = trim;
|
|
2785
2915
|
exports.trimEnd = trimEnd;
|
|
2786
2916
|
exports.trimStart = trimStart;
|
|
@@ -2792,5 +2922,6 @@ exports.unset = unset;
|
|
|
2792
2922
|
exports.unzip = unzip;
|
|
2793
2923
|
exports.upperCase = upperCase;
|
|
2794
2924
|
exports.without = without;
|
|
2925
|
+
exports.words = words;
|
|
2795
2926
|
exports.zip = zip;
|
|
2796
2927
|
exports.zipObjectDeep = zipObjectDeep;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -56,6 +56,7 @@ export { omitBy } from '../object/omitBy.mjs';
|
|
|
56
56
|
export { pickBy } from '../object/pickBy.mjs';
|
|
57
57
|
export { toMerged } from '../object/toMerged.mjs';
|
|
58
58
|
export { isBlob } from '../predicate/isBlob.mjs';
|
|
59
|
+
export { isBuffer } from '../predicate/isBuffer.mjs';
|
|
59
60
|
export { isEqual } from '../predicate/isEqual.mjs';
|
|
60
61
|
export { eq } from './util/eq.mjs';
|
|
61
62
|
export { isFile } from '../predicate/isFile.mjs';
|
|
@@ -69,7 +70,6 @@ export { delay } from '../promise/delay.mjs';
|
|
|
69
70
|
export { timeout } from '../promise/timeout.mjs';
|
|
70
71
|
export { withTimeout } from '../promise/withTimeout.mjs';
|
|
71
72
|
export { capitalize } from '../string/capitalize.mjs';
|
|
72
|
-
export { words } from '../string/words.mjs';
|
|
73
73
|
export { constantCase } from '../string/constantCase.mjs';
|
|
74
74
|
export { deburr } from '../string/deburr.mjs';
|
|
75
75
|
export { escapeRegExp } from '../string/escapeRegExp.mjs';
|
|
@@ -137,6 +137,7 @@ export { rearg } from './function/rearg.mjs';
|
|
|
137
137
|
export { rest } from './function/rest.mjs';
|
|
138
138
|
export { spread } from './function/spread.mjs';
|
|
139
139
|
export { throttle } from './function/throttle.mjs';
|
|
140
|
+
export { add } from './math/add.mjs';
|
|
140
141
|
export { ceil } from './math/ceil.mjs';
|
|
141
142
|
export { clamp } from './math/clamp.mjs';
|
|
142
143
|
export { floor } from './math/floor.mjs';
|
|
@@ -148,12 +149,14 @@ export { random } from './math/random.mjs';
|
|
|
148
149
|
export { round } from './math/round.mjs';
|
|
149
150
|
export { sum } from './math/sum.mjs';
|
|
150
151
|
export { sumBy } from './math/sumBy.mjs';
|
|
152
|
+
export { assignIn, assignIn as extend } from './object/assignIn.mjs';
|
|
151
153
|
export { cloneDeep } from './object/cloneDeep.mjs';
|
|
152
154
|
export { defaults } from './object/defaults.mjs';
|
|
153
155
|
export { fromPairs } from './object/fromPairs.mjs';
|
|
154
156
|
export { get } from './object/get.mjs';
|
|
155
157
|
export { has } from './object/has.mjs';
|
|
156
158
|
export { invertBy } from './object/invertBy.mjs';
|
|
159
|
+
export { keysIn } from './object/keysIn.mjs';
|
|
157
160
|
export { mapKeys } from './object/mapKeys.mjs';
|
|
158
161
|
export { mapValues } from './object/mapValues.mjs';
|
|
159
162
|
export { merge } from './object/merge.mjs';
|
|
@@ -173,6 +176,7 @@ export { isArrayLike } from './predicate/isArrayLike.mjs';
|
|
|
173
176
|
export { isArrayLikeObject } from './predicate/isArrayLikeObject.mjs';
|
|
174
177
|
export { isBoolean } from './predicate/isBoolean.mjs';
|
|
175
178
|
export { isDate } from './predicate/isDate.mjs';
|
|
179
|
+
export { isElement } from './predicate/isElement.mjs';
|
|
176
180
|
export { isEmpty } from './predicate/isEmpty.mjs';
|
|
177
181
|
export { isEqualWith } from './predicate/isEqualWith.mjs';
|
|
178
182
|
export { isError } from './predicate/isError.mjs';
|
|
@@ -209,14 +213,19 @@ export { snakeCase } from './string/snakeCase.mjs';
|
|
|
209
213
|
export { startCase } from './string/startCase.mjs';
|
|
210
214
|
export { startsWith } from './string/startsWith.mjs';
|
|
211
215
|
export { template, templateSettings } from './string/template.mjs';
|
|
216
|
+
export { toUpper } from './string/toUpper.mjs';
|
|
212
217
|
export { trim } from './string/trim.mjs';
|
|
213
218
|
export { trimEnd } from './string/trimEnd.mjs';
|
|
214
219
|
export { trimStart } from './string/trimStart.mjs';
|
|
215
220
|
export { upperCase } from './string/upperCase.mjs';
|
|
221
|
+
export { words } from './string/words.mjs';
|
|
216
222
|
export { constant } from './util/constant.mjs';
|
|
217
223
|
export { defaultTo } from './util/defaultTo.mjs';
|
|
224
|
+
export { gt } from './util/gt.mjs';
|
|
225
|
+
export { gte } from './util/gte.mjs';
|
|
218
226
|
export { iteratee } from './util/iteratee.mjs';
|
|
219
227
|
export { times } from './util/times.mjs';
|
|
228
|
+
export { toArray } from './util/toArray.mjs';
|
|
220
229
|
export { toFinite } from './util/toFinite.mjs';
|
|
221
230
|
export { toInteger } from './util/toInteger.mjs';
|
|
222
231
|
export { toLength } from './util/toLength.mjs';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds two numbers while safely handling `NaN` values.
|
|
3
|
+
*
|
|
4
|
+
* This function takes two numbers and returns their sum. If either of the numbers is `NaN`,
|
|
5
|
+
* the function returns `NaN`.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} value - The first number to add.
|
|
8
|
+
* @param {number} other - The second number to add.
|
|
9
|
+
* @returns {number} The sum of the two numbers, or `NaN` if any input is `NaN`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const result1 = add(2, 3); // result1 will be 5
|
|
13
|
+
* const result2 = add(5, NaN); // result2 will be NaN
|
|
14
|
+
* const result3 = add(NaN, 10); // result3 will be NaN
|
|
15
|
+
*/
|
|
16
|
+
declare function add(value: number, other: number): number;
|
|
17
|
+
|
|
18
|
+
export { add };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds two numbers while safely handling `NaN` values.
|
|
3
|
+
*
|
|
4
|
+
* This function takes two numbers and returns their sum. If either of the numbers is `NaN`,
|
|
5
|
+
* the function returns `NaN`.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} value - The first number to add.
|
|
8
|
+
* @param {number} other - The second number to add.
|
|
9
|
+
* @returns {number} The sum of the two numbers, or `NaN` if any input is `NaN`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const result1 = add(2, 3); // result1 will be 5
|
|
13
|
+
* const result2 = add(5, NaN); // result2 will be NaN
|
|
14
|
+
* const result3 = add(NaN, 10); // result3 will be NaN
|
|
15
|
+
*/
|
|
16
|
+
declare function add(value: number, other: number): number;
|
|
17
|
+
|
|
18
|
+
export { add };
|