es-toolkit 1.35.0-dev.1206 → 1.35.0-dev.1211
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/_chunk/{toSnakeCaseKeys-DCXJ3Q.js → toSnakeCaseKeys-nofgoP.js} +87 -81
- package/dist/_chunk/{zipWith-ChDTPy.js → zipWith-Bt0YQl.js} +38 -11
- package/dist/array/index.js +9 -2
- package/dist/array/take.d.mts +1 -1
- package/dist/array/take.d.ts +1 -1
- package/dist/array/take.mjs +4 -1
- package/dist/array/takeRight.d.mts +1 -1
- package/dist/array/takeRight.d.ts +1 -1
- package/dist/array/takeRight.mjs +5 -2
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/forEachRight.d.mts +106 -0
- package/dist/compat/array/forEachRight.d.ts +106 -0
- package/dist/compat/array/forEachRight.mjs +21 -0
- package/dist/compat/array/groupBy.d.mts +55 -0
- package/dist/compat/array/groupBy.d.ts +55 -0
- package/dist/compat/array/groupBy.mjs +15 -0
- package/dist/compat/compat.d.mts +2 -2
- package/dist/compat/compat.d.ts +2 -2
- package/dist/compat/compat.mjs +3 -3
- package/dist/compat/index.d.mts +2 -2
- package/dist/compat/index.d.ts +2 -2
- package/dist/compat/index.js +8 -8
- package/dist/compat/index.mjs +3 -3
- package/dist/compat/object/defaults.mjs +7 -1
- package/dist/compat/string/repeat.d.mts +1 -1
- package/dist/compat/string/repeat.d.ts +1 -1
- package/dist/compat/string/repeat.mjs +12 -2
- package/dist/compat/string/words.d.mts +1 -1
- package/dist/compat/string/words.d.ts +1 -1
- package/dist/compat/string/words.mjs +2 -1
- package/dist/index.js +3 -3
- package/dist/object/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const zipWith = require('./zipWith-
|
|
3
|
+
const zipWith = require('./zipWith-Bt0YQl.js');
|
|
4
4
|
const AbortError = require('./AbortError-Cg4ZQ1.js');
|
|
5
5
|
const error_index = require('../error/index.js');
|
|
6
6
|
const unary = require('./unary-EIEhcF.js');
|
|
@@ -805,40 +805,11 @@ function differenceWith(array, ...values) {
|
|
|
805
805
|
return zipWith.difference(Array.from(array), flattenedValues);
|
|
806
806
|
}
|
|
807
807
|
|
|
808
|
-
function isSymbol(value) {
|
|
809
|
-
return typeof value === 'symbol' || value instanceof Symbol;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
function toNumber(value) {
|
|
813
|
-
if (isSymbol(value)) {
|
|
814
|
-
return NaN;
|
|
815
|
-
}
|
|
816
|
-
return Number(value);
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
function toFinite(value) {
|
|
820
|
-
if (!value) {
|
|
821
|
-
return value === 0 ? value : 0;
|
|
822
|
-
}
|
|
823
|
-
value = toNumber(value);
|
|
824
|
-
if (value === Infinity || value === -Infinity) {
|
|
825
|
-
const sign = value < 0 ? -1 : 1;
|
|
826
|
-
return sign * Number.MAX_VALUE;
|
|
827
|
-
}
|
|
828
|
-
return value === value ? value : 0;
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
function toInteger(value) {
|
|
832
|
-
const finite = toFinite(value);
|
|
833
|
-
const remainder = finite % 1;
|
|
834
|
-
return remainder ? finite - remainder : finite;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
808
|
function drop(collection, itemsCount = 1, guard) {
|
|
838
809
|
if (!isArrayLike(collection)) {
|
|
839
810
|
return [];
|
|
840
811
|
}
|
|
841
|
-
itemsCount = guard ? 1 : toInteger(itemsCount);
|
|
812
|
+
itemsCount = guard ? 1 : zipWith.toInteger(itemsCount);
|
|
842
813
|
return zipWith.drop(toArray$1(collection), itemsCount);
|
|
843
814
|
}
|
|
844
815
|
|
|
@@ -846,7 +817,7 @@ function dropRight(collection, itemsCount = 1, guard) {
|
|
|
846
817
|
if (!isArrayLike(collection)) {
|
|
847
818
|
return [];
|
|
848
819
|
}
|
|
849
|
-
itemsCount = guard ? 1 : toInteger(itemsCount);
|
|
820
|
+
itemsCount = guard ? 1 : zipWith.toInteger(itemsCount);
|
|
850
821
|
return zipWith.dropRight(toArray$1(collection), itemsCount);
|
|
851
822
|
}
|
|
852
823
|
|
|
@@ -1073,7 +1044,7 @@ function findLast(source, _doesMatch, fromIndex) {
|
|
|
1073
1044
|
return undefined;
|
|
1074
1045
|
}
|
|
1075
1046
|
const length = Array.isArray(source) ? source.length : Object.keys(source).length;
|
|
1076
|
-
fromIndex = toInteger(fromIndex ?? length - 1);
|
|
1047
|
+
fromIndex = zipWith.toInteger(fromIndex ?? length - 1);
|
|
1077
1048
|
if (fromIndex < 0) {
|
|
1078
1049
|
fromIndex = Math.max(length + fromIndex, 0);
|
|
1079
1050
|
}
|
|
@@ -1182,6 +1153,31 @@ function forEach(collection, callback = unary.identity) {
|
|
|
1182
1153
|
return collection;
|
|
1183
1154
|
}
|
|
1184
1155
|
|
|
1156
|
+
function forEachRight(collection, callback = unary.identity) {
|
|
1157
|
+
if (!collection) {
|
|
1158
|
+
return collection;
|
|
1159
|
+
}
|
|
1160
|
+
const keys = isArrayLike(collection) ? range$1.range(0, collection.length) : Object.keys(collection);
|
|
1161
|
+
for (let i = keys.length - 1; i >= 0; i--) {
|
|
1162
|
+
const key = keys[i];
|
|
1163
|
+
const value = collection[key];
|
|
1164
|
+
const result = callback(value, key, collection);
|
|
1165
|
+
if (result === false) {
|
|
1166
|
+
break;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
return collection;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
function groupBy(source, _getKeyFromItem) {
|
|
1173
|
+
if (source == null) {
|
|
1174
|
+
return {};
|
|
1175
|
+
}
|
|
1176
|
+
const items = isArrayLike(source) ? Array.from(source) : Object.values(source);
|
|
1177
|
+
const getKeyFromItem = iteratee(_getKeyFromItem ?? unary.identity);
|
|
1178
|
+
return zipWith.groupBy(items, getKeyFromItem);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1185
1181
|
function head(arr) {
|
|
1186
1182
|
if (!isArrayLike(arr)) {
|
|
1187
1183
|
return undefined;
|
|
@@ -1197,7 +1193,7 @@ function includes(source, target, fromIndex, guard) {
|
|
|
1197
1193
|
fromIndex = 0;
|
|
1198
1194
|
}
|
|
1199
1195
|
else {
|
|
1200
|
-
fromIndex = toInteger(fromIndex);
|
|
1196
|
+
fromIndex = zipWith.toInteger(fromIndex);
|
|
1201
1197
|
}
|
|
1202
1198
|
if (isString(source)) {
|
|
1203
1199
|
if (fromIndex > source.length || target instanceof RegExp) {
|
|
@@ -1377,7 +1373,7 @@ function nth(array, n = 0) {
|
|
|
1377
1373
|
if (!isArrayLikeObject(array) || array.length === 0) {
|
|
1378
1374
|
return undefined;
|
|
1379
1375
|
}
|
|
1380
|
-
n = toInteger(n);
|
|
1376
|
+
n = zipWith.toInteger(n);
|
|
1381
1377
|
if (n < 0) {
|
|
1382
1378
|
n += array.length;
|
|
1383
1379
|
}
|
|
@@ -1425,7 +1421,7 @@ function isKey(value, object) {
|
|
|
1425
1421
|
if (Array.isArray(value)) {
|
|
1426
1422
|
return false;
|
|
1427
1423
|
}
|
|
1428
|
-
if (typeof value === 'number' || typeof value === 'boolean' || value == null || isSymbol(value)) {
|
|
1424
|
+
if (typeof value === 'number' || typeof value === 'boolean' || value == null || zipWith.isSymbol(value)) {
|
|
1429
1425
|
return true;
|
|
1430
1426
|
}
|
|
1431
1427
|
return ((typeof value === 'string' && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value))) ||
|
|
@@ -1650,8 +1646,8 @@ function slice(array, start, end) {
|
|
|
1650
1646
|
start = 0;
|
|
1651
1647
|
end = length;
|
|
1652
1648
|
}
|
|
1653
|
-
start = toInteger(start);
|
|
1654
|
-
end = toInteger(end);
|
|
1649
|
+
start = zipWith.toInteger(start);
|
|
1650
|
+
end = zipWith.toInteger(end);
|
|
1655
1651
|
if (start < 0) {
|
|
1656
1652
|
start = Math.max(length + start, 0);
|
|
1657
1653
|
}
|
|
@@ -1747,7 +1743,7 @@ function sortedIndexBy(array, value, iteratee$1, retHighest) {
|
|
|
1747
1743
|
const transformedValue = iterateeFunction(value);
|
|
1748
1744
|
const valIsNaN = isNaN(transformedValue);
|
|
1749
1745
|
const valIsNull = isPromise.isNull(transformedValue);
|
|
1750
|
-
const valIsSymbol = isSymbol(transformedValue);
|
|
1746
|
+
const valIsSymbol = zipWith.isSymbol(transformedValue);
|
|
1751
1747
|
const valIsUndefined = isPromise.isUndefined(transformedValue);
|
|
1752
1748
|
while (low < high) {
|
|
1753
1749
|
let setLow;
|
|
@@ -1756,7 +1752,7 @@ function sortedIndexBy(array, value, iteratee$1, retHighest) {
|
|
|
1756
1752
|
const othIsDefined = !isPromise.isUndefined(computed);
|
|
1757
1753
|
const othIsNull = isPromise.isNull(computed);
|
|
1758
1754
|
const othIsReflexive = !isNaN(computed);
|
|
1759
|
-
const othIsSymbol = isSymbol(computed);
|
|
1755
|
+
const othIsSymbol = zipWith.isSymbol(computed);
|
|
1760
1756
|
if (valIsNaN) {
|
|
1761
1757
|
setLow = retHighest || othIsReflexive;
|
|
1762
1758
|
}
|
|
@@ -1859,7 +1855,7 @@ function tail(arr) {
|
|
|
1859
1855
|
}
|
|
1860
1856
|
|
|
1861
1857
|
function take(arr, count = 1, guard) {
|
|
1862
|
-
count = guard ? 1 : toInteger(count);
|
|
1858
|
+
count = guard ? 1 : zipWith.toInteger(count);
|
|
1863
1859
|
if (count < 1 || !isArrayLike(arr)) {
|
|
1864
1860
|
return [];
|
|
1865
1861
|
}
|
|
@@ -1867,7 +1863,7 @@ function take(arr, count = 1, guard) {
|
|
|
1867
1863
|
}
|
|
1868
1864
|
|
|
1869
1865
|
function takeRight(arr, count = 1, guard) {
|
|
1870
|
-
count = guard ? 1 : toInteger(count);
|
|
1866
|
+
count = guard ? 1 : zipWith.toInteger(count);
|
|
1871
1867
|
if (count <= 0 || !isArrayLike(arr)) {
|
|
1872
1868
|
return [];
|
|
1873
1869
|
}
|
|
@@ -2022,7 +2018,7 @@ function after(n, func) {
|
|
|
2022
2018
|
if (typeof func !== 'function') {
|
|
2023
2019
|
throw new TypeError('Expected a function');
|
|
2024
2020
|
}
|
|
2025
|
-
n = toInteger(n);
|
|
2021
|
+
n = zipWith.toInteger(n);
|
|
2026
2022
|
return function (...args) {
|
|
2027
2023
|
if (--n < 1) {
|
|
2028
2024
|
return func.apply(this, args);
|
|
@@ -2054,7 +2050,7 @@ function before(n, func) {
|
|
|
2054
2050
|
throw new TypeError('Expected a function');
|
|
2055
2051
|
}
|
|
2056
2052
|
let result;
|
|
2057
|
-
n = toInteger(n);
|
|
2053
|
+
n = zipWith.toInteger(n);
|
|
2058
2054
|
return function (...args) {
|
|
2059
2055
|
if (--n > 0) {
|
|
2060
2056
|
result = func.apply(this, args);
|
|
@@ -2293,7 +2289,7 @@ function delay(func, wait, ...args) {
|
|
|
2293
2289
|
if (typeof func !== 'function') {
|
|
2294
2290
|
throw new TypeError('Expected a function');
|
|
2295
2291
|
}
|
|
2296
|
-
return setTimeout(func, toNumber(wait) || 0, ...args);
|
|
2292
|
+
return setTimeout(func, zipWith.toNumber(wait) || 0, ...args);
|
|
2297
2293
|
}
|
|
2298
2294
|
|
|
2299
2295
|
function flip(func) {
|
|
@@ -2320,7 +2316,7 @@ function flowRight(...funcs) {
|
|
|
2320
2316
|
|
|
2321
2317
|
function nthArg(n = 0) {
|
|
2322
2318
|
return function (...args) {
|
|
2323
|
-
return args.at(toInteger(n));
|
|
2319
|
+
return args.at(zipWith.toInteger(n));
|
|
2324
2320
|
};
|
|
2325
2321
|
}
|
|
2326
2322
|
|
|
@@ -2407,8 +2403,8 @@ function add(value, other) {
|
|
|
2407
2403
|
other = toString(other);
|
|
2408
2404
|
}
|
|
2409
2405
|
else {
|
|
2410
|
-
value = toNumber(value);
|
|
2411
|
-
other = toNumber(other);
|
|
2406
|
+
value = zipWith.toNumber(value);
|
|
2407
|
+
other = zipWith.toNumber(other);
|
|
2412
2408
|
}
|
|
2413
2409
|
return value + other;
|
|
2414
2410
|
}
|
|
@@ -2457,8 +2453,8 @@ function divide(value, other) {
|
|
|
2457
2453
|
other = toString(other);
|
|
2458
2454
|
}
|
|
2459
2455
|
else {
|
|
2460
|
-
value = toNumber(value);
|
|
2461
|
-
other = toNumber(other);
|
|
2456
|
+
value = zipWith.toNumber(value);
|
|
2457
|
+
other = zipWith.toNumber(other);
|
|
2462
2458
|
}
|
|
2463
2459
|
return value / other;
|
|
2464
2460
|
}
|
|
@@ -2582,8 +2578,8 @@ function multiply(value, other) {
|
|
|
2582
2578
|
other = toString(other);
|
|
2583
2579
|
}
|
|
2584
2580
|
else {
|
|
2585
|
-
value = toNumber(value);
|
|
2586
|
-
other = toNumber(other);
|
|
2581
|
+
value = zipWith.toNumber(value);
|
|
2582
|
+
other = zipWith.toNumber(other);
|
|
2587
2583
|
}
|
|
2588
2584
|
return value * other;
|
|
2589
2585
|
}
|
|
@@ -2664,15 +2660,15 @@ function range(start, end, step) {
|
|
|
2664
2660
|
if (step && typeof step !== 'number' && isIterateeCall(start, end, step)) {
|
|
2665
2661
|
end = step = undefined;
|
|
2666
2662
|
}
|
|
2667
|
-
start = toFinite(start);
|
|
2663
|
+
start = zipWith.toFinite(start);
|
|
2668
2664
|
if (end === undefined) {
|
|
2669
2665
|
end = start;
|
|
2670
2666
|
start = 0;
|
|
2671
2667
|
}
|
|
2672
2668
|
else {
|
|
2673
|
-
end = toFinite(end);
|
|
2669
|
+
end = zipWith.toFinite(end);
|
|
2674
2670
|
}
|
|
2675
|
-
step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
|
|
2671
|
+
step = step === undefined ? (start < end ? 1 : -1) : zipWith.toFinite(step);
|
|
2676
2672
|
const length = Math.max(Math.ceil((end - start) / (step || 1)), 0);
|
|
2677
2673
|
const result = new Array(length);
|
|
2678
2674
|
for (let index = 0; index < length; index++) {
|
|
@@ -2686,15 +2682,15 @@ function rangeRight(start, end, step) {
|
|
|
2686
2682
|
if (step && typeof step !== 'number' && isIterateeCall(start, end, step)) {
|
|
2687
2683
|
end = step = undefined;
|
|
2688
2684
|
}
|
|
2689
|
-
start = toFinite(start);
|
|
2685
|
+
start = zipWith.toFinite(start);
|
|
2690
2686
|
if (end === undefined) {
|
|
2691
2687
|
end = start;
|
|
2692
2688
|
start = 0;
|
|
2693
2689
|
}
|
|
2694
2690
|
else {
|
|
2695
|
-
end = toFinite(end);
|
|
2691
|
+
end = zipWith.toFinite(end);
|
|
2696
2692
|
}
|
|
2697
|
-
step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
|
|
2693
|
+
step = step === undefined ? (start < end ? 1 : -1) : zipWith.toFinite(step);
|
|
2698
2694
|
const length = Math.max(Math.ceil((end - start) / (step || 1)), 0);
|
|
2699
2695
|
const result = new Array(length);
|
|
2700
2696
|
for (let index = length - 1; index >= 0; index--) {
|
|
@@ -2720,8 +2716,8 @@ function subtract(value, other) {
|
|
|
2720
2716
|
other = toString(other);
|
|
2721
2717
|
}
|
|
2722
2718
|
else {
|
|
2723
|
-
value = toNumber(value);
|
|
2724
|
-
other = toNumber(other);
|
|
2719
|
+
value = zipWith.toNumber(value);
|
|
2720
|
+
other = zipWith.toNumber(other);
|
|
2725
2721
|
}
|
|
2726
2722
|
return value - other;
|
|
2727
2723
|
}
|
|
@@ -2737,7 +2733,7 @@ function isTypedArray(x) {
|
|
|
2737
2733
|
}
|
|
2738
2734
|
|
|
2739
2735
|
function times(n, getValue) {
|
|
2740
|
-
n = toInteger(n);
|
|
2736
|
+
n = zipWith.toInteger(n);
|
|
2741
2737
|
if (n < 1 || !Number.isSafeInteger(n)) {
|
|
2742
2738
|
return [];
|
|
2743
2739
|
}
|
|
@@ -2919,7 +2915,12 @@ function create(prototype, properties) {
|
|
|
2919
2915
|
function defaults(object, ...sources) {
|
|
2920
2916
|
object = Object(object);
|
|
2921
2917
|
const objectProto = Object.prototype;
|
|
2922
|
-
|
|
2918
|
+
let length = sources.length;
|
|
2919
|
+
const guard = length > 2 ? sources[2] : undefined;
|
|
2920
|
+
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
|
2921
|
+
length = 1;
|
|
2922
|
+
}
|
|
2923
|
+
for (let i = 0; i < length; i++) {
|
|
2923
2924
|
const source = sources[i];
|
|
2924
2925
|
const keys = Object.keys(source);
|
|
2925
2926
|
for (let j = 0; j < keys.length; j++) {
|
|
@@ -3303,7 +3304,7 @@ function pickBy(obj, shouldPick) {
|
|
|
3303
3304
|
}
|
|
3304
3305
|
const keys = isArrayLike(obj) ? range$1.range(0, obj.length) : [...keysIn(obj), ...getSymbolsIn(obj)];
|
|
3305
3306
|
for (let i = 0; i < keys.length; i++) {
|
|
3306
|
-
const key = (isSymbol(keys[i]) ? keys[i] : keys[i].toString());
|
|
3307
|
+
const key = (zipWith.isSymbol(keys[i]) ? keys[i] : keys[i].toString());
|
|
3307
3308
|
const value = obj[key];
|
|
3308
3309
|
if (shouldPick(value, key, obj)) {
|
|
3309
3310
|
result[key] = value;
|
|
@@ -3573,8 +3574,14 @@ function padStart(str, length = 0, chars = ' ') {
|
|
|
3573
3574
|
return toString(str).padStart(length, chars);
|
|
3574
3575
|
}
|
|
3575
3576
|
|
|
3576
|
-
function repeat(str, n) {
|
|
3577
|
-
|
|
3577
|
+
function repeat(str, n, guard) {
|
|
3578
|
+
if (guard ? isIterateeCall(str, n, guard) : n === undefined) {
|
|
3579
|
+
n = 1;
|
|
3580
|
+
}
|
|
3581
|
+
else {
|
|
3582
|
+
n = zipWith.toInteger(n);
|
|
3583
|
+
}
|
|
3584
|
+
return toString(str).repeat(n);
|
|
3578
3585
|
}
|
|
3579
3586
|
|
|
3580
3587
|
function replace(target = '', pattern, replacement) {
|
|
@@ -3776,8 +3783,9 @@ function upperFirst(str) {
|
|
|
3776
3783
|
return reverseString.upperFirst(toString(str));
|
|
3777
3784
|
}
|
|
3778
3785
|
|
|
3779
|
-
function words(str, pattern = reverseString.CASE_SPLIT_PATTERN) {
|
|
3786
|
+
function words(str, pattern = reverseString.CASE_SPLIT_PATTERN, guard) {
|
|
3780
3787
|
const input = toString(str);
|
|
3788
|
+
pattern = guard ? reverseString.CASE_SPLIT_PATTERN : pattern;
|
|
3781
3789
|
const words = Array.from(input.match(pattern) ?? []);
|
|
3782
3790
|
return words.filter(x => x !== '');
|
|
3783
3791
|
}
|
|
@@ -3819,14 +3827,14 @@ function gt(value, other) {
|
|
|
3819
3827
|
if (typeof value === 'string' && typeof other === 'string') {
|
|
3820
3828
|
return value > other;
|
|
3821
3829
|
}
|
|
3822
|
-
return toNumber(value) > toNumber(other);
|
|
3830
|
+
return zipWith.toNumber(value) > zipWith.toNumber(other);
|
|
3823
3831
|
}
|
|
3824
3832
|
|
|
3825
3833
|
function gte(value, other) {
|
|
3826
3834
|
if (typeof value === 'string' && typeof other === 'string') {
|
|
3827
3835
|
return value >= other;
|
|
3828
3836
|
}
|
|
3829
|
-
return toNumber(value) >= toNumber(other);
|
|
3837
|
+
return zipWith.toNumber(value) >= zipWith.toNumber(other);
|
|
3830
3838
|
}
|
|
3831
3839
|
|
|
3832
3840
|
function invoke(object, path, args = []) {
|
|
@@ -3875,14 +3883,14 @@ function lt(value, other) {
|
|
|
3875
3883
|
if (typeof value === 'string' && typeof other === 'string') {
|
|
3876
3884
|
return value < other;
|
|
3877
3885
|
}
|
|
3878
|
-
return toNumber(value) < toNumber(other);
|
|
3886
|
+
return zipWith.toNumber(value) < zipWith.toNumber(other);
|
|
3879
3887
|
}
|
|
3880
3888
|
|
|
3881
3889
|
function lte(value, other) {
|
|
3882
3890
|
if (typeof value === 'string' && typeof other === 'string') {
|
|
3883
3891
|
return value <= other;
|
|
3884
3892
|
}
|
|
3885
|
-
return toNumber(value) <= toNumber(other);
|
|
3893
|
+
return zipWith.toNumber(value) <= zipWith.toNumber(other);
|
|
3886
3894
|
}
|
|
3887
3895
|
|
|
3888
3896
|
function method(path, ...args) {
|
|
@@ -3981,7 +3989,7 @@ function toSafeInteger(value) {
|
|
|
3981
3989
|
if (value == null) {
|
|
3982
3990
|
return 0;
|
|
3983
3991
|
}
|
|
3984
|
-
return clamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
|
|
3992
|
+
return clamp(zipWith.toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
|
|
3985
3993
|
}
|
|
3986
3994
|
|
|
3987
3995
|
let idCounter = 0;
|
|
@@ -4071,12 +4079,12 @@ const compat = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
4071
4079
|
flow,
|
|
4072
4080
|
flowRight,
|
|
4073
4081
|
forEach,
|
|
4074
|
-
forEachRight
|
|
4082
|
+
forEachRight,
|
|
4075
4083
|
fromPairs,
|
|
4076
4084
|
functions,
|
|
4077
4085
|
functionsIn,
|
|
4078
4086
|
get,
|
|
4079
|
-
groupBy
|
|
4087
|
+
groupBy,
|
|
4080
4088
|
gt,
|
|
4081
4089
|
gte,
|
|
4082
4090
|
has,
|
|
@@ -4136,7 +4144,7 @@ const compat = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
4136
4144
|
isString,
|
|
4137
4145
|
isSubset: zipWith.isSubset,
|
|
4138
4146
|
isSubsetWith: zipWith.isSubsetWith,
|
|
4139
|
-
isSymbol,
|
|
4147
|
+
isSymbol: zipWith.isSymbol,
|
|
4140
4148
|
isTypedArray,
|
|
4141
4149
|
isUndefined: isPromise.isUndefined,
|
|
4142
4150
|
isWeakMap,
|
|
@@ -4253,12 +4261,12 @@ const compat = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
4253
4261
|
toCamelCaseKeys,
|
|
4254
4262
|
toDefaulted,
|
|
4255
4263
|
toFilled: zipWith.toFilled,
|
|
4256
|
-
toFinite,
|
|
4257
|
-
toInteger,
|
|
4264
|
+
toFinite: zipWith.toFinite,
|
|
4265
|
+
toInteger: zipWith.toInteger,
|
|
4258
4266
|
toLength,
|
|
4259
4267
|
toLower,
|
|
4260
4268
|
toMerged,
|
|
4261
|
-
toNumber,
|
|
4269
|
+
toNumber: zipWith.toNumber,
|
|
4262
4270
|
toPairs,
|
|
4263
4271
|
toPairsIn,
|
|
4264
4272
|
toPath,
|
|
@@ -4413,10 +4421,12 @@ exports.floor = floor;
|
|
|
4413
4421
|
exports.flow = flow;
|
|
4414
4422
|
exports.flowRight = flowRight;
|
|
4415
4423
|
exports.forEach = forEach;
|
|
4424
|
+
exports.forEachRight = forEachRight;
|
|
4416
4425
|
exports.fromPairs = fromPairs;
|
|
4417
4426
|
exports.functions = functions;
|
|
4418
4427
|
exports.functionsIn = functionsIn;
|
|
4419
4428
|
exports.get = get;
|
|
4429
|
+
exports.groupBy = groupBy;
|
|
4420
4430
|
exports.gt = gt;
|
|
4421
4431
|
exports.gte = gte;
|
|
4422
4432
|
exports.has = has;
|
|
@@ -4456,7 +4466,6 @@ exports.isRegExp = isRegExp;
|
|
|
4456
4466
|
exports.isSafeInteger = isSafeInteger;
|
|
4457
4467
|
exports.isSet = isSet;
|
|
4458
4468
|
exports.isString = isString;
|
|
4459
|
-
exports.isSymbol = isSymbol;
|
|
4460
4469
|
exports.isTypedArray = isTypedArray;
|
|
4461
4470
|
exports.isWeakMap = isWeakMap;
|
|
4462
4471
|
exports.isWeakSet = isWeakSet;
|
|
@@ -4559,12 +4568,9 @@ exports.times = times;
|
|
|
4559
4568
|
exports.toArray = toArray;
|
|
4560
4569
|
exports.toCamelCaseKeys = toCamelCaseKeys;
|
|
4561
4570
|
exports.toDefaulted = toDefaulted;
|
|
4562
|
-
exports.toFinite = toFinite;
|
|
4563
|
-
exports.toInteger = toInteger;
|
|
4564
4571
|
exports.toLength = toLength;
|
|
4565
4572
|
exports.toLower = toLower;
|
|
4566
4573
|
exports.toMerged = toMerged;
|
|
4567
|
-
exports.toNumber = toNumber;
|
|
4568
4574
|
exports.toPairs = toPairs;
|
|
4569
4575
|
exports.toPairsIn = toPairsIn;
|
|
4570
4576
|
exports.toPath = toPath;
|
|
@@ -141,13 +141,6 @@ function flatMapDeep(arr, iteratee) {
|
|
|
141
141
|
return flattenDeep(arr.map((item) => iteratee(item)));
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
function forEachRight(arr, callback) {
|
|
145
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
|
146
|
-
const element = arr[i];
|
|
147
|
-
callback(element, i, arr);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
144
|
function groupBy(arr, getKeyFromItem) {
|
|
152
145
|
const result = {};
|
|
153
146
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -334,12 +327,43 @@ function tail(arr) {
|
|
|
334
327
|
return arr.slice(1);
|
|
335
328
|
}
|
|
336
329
|
|
|
337
|
-
function
|
|
330
|
+
function isSymbol(value) {
|
|
331
|
+
return typeof value === 'symbol' || value instanceof Symbol;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function toNumber(value) {
|
|
335
|
+
if (isSymbol(value)) {
|
|
336
|
+
return NaN;
|
|
337
|
+
}
|
|
338
|
+
return Number(value);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function toFinite(value) {
|
|
342
|
+
if (!value) {
|
|
343
|
+
return value === 0 ? value : 0;
|
|
344
|
+
}
|
|
345
|
+
value = toNumber(value);
|
|
346
|
+
if (value === Infinity || value === -Infinity) {
|
|
347
|
+
const sign = value < 0 ? -1 : 1;
|
|
348
|
+
return sign * Number.MAX_VALUE;
|
|
349
|
+
}
|
|
350
|
+
return value === value ? value : 0;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function toInteger(value) {
|
|
354
|
+
const finite = toFinite(value);
|
|
355
|
+
const remainder = finite % 1;
|
|
356
|
+
return remainder ? finite - remainder : finite;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function take(arr, count, guard) {
|
|
360
|
+
count = guard || count === undefined ? 1 : toInteger(count);
|
|
338
361
|
return arr.slice(0, count);
|
|
339
362
|
}
|
|
340
363
|
|
|
341
|
-
function takeRight(arr, count = 1) {
|
|
342
|
-
|
|
364
|
+
function takeRight(arr, count = 1, guard) {
|
|
365
|
+
count = guard || count === undefined ? 1 : toInteger(count);
|
|
366
|
+
if (count <= 0 || arr == null || arr.length === 0) {
|
|
343
367
|
return [];
|
|
344
368
|
}
|
|
345
369
|
return arr.slice(-count);
|
|
@@ -516,7 +540,6 @@ exports.flatMap = flatMap;
|
|
|
516
540
|
exports.flatMapDeep = flatMapDeep;
|
|
517
541
|
exports.flatten = flatten;
|
|
518
542
|
exports.flattenDeep = flattenDeep;
|
|
519
|
-
exports.forEachRight = forEachRight;
|
|
520
543
|
exports.groupBy = groupBy;
|
|
521
544
|
exports.head = head;
|
|
522
545
|
exports.initial = initial;
|
|
@@ -525,6 +548,7 @@ exports.intersectionBy = intersectionBy;
|
|
|
525
548
|
exports.intersectionWith = intersectionWith;
|
|
526
549
|
exports.isSubset = isSubset;
|
|
527
550
|
exports.isSubsetWith = isSubsetWith;
|
|
551
|
+
exports.isSymbol = isSymbol;
|
|
528
552
|
exports.keyBy = keyBy;
|
|
529
553
|
exports.last = last;
|
|
530
554
|
exports.maxBy = maxBy;
|
|
@@ -540,6 +564,9 @@ exports.tail = tail;
|
|
|
540
564
|
exports.take = take;
|
|
541
565
|
exports.takeRight = takeRight;
|
|
542
566
|
exports.toFilled = toFilled;
|
|
567
|
+
exports.toFinite = toFinite;
|
|
568
|
+
exports.toInteger = toInteger;
|
|
569
|
+
exports.toNumber = toNumber;
|
|
543
570
|
exports.union = union;
|
|
544
571
|
exports.unionBy = unionBy;
|
|
545
572
|
exports.unionWith = unionWith;
|
package/dist/array/index.js
CHANGED
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const zipWith = require('../_chunk/zipWith-
|
|
5
|
+
const zipWith = require('../_chunk/zipWith-Bt0YQl.js');
|
|
6
|
+
|
|
7
|
+
function forEachRight(arr, callback) {
|
|
8
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
9
|
+
const element = arr[i];
|
|
10
|
+
callback(element, i, arr);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
function compareValues(a, b, order) {
|
|
8
15
|
if (a < b) {
|
|
@@ -73,7 +80,6 @@ exports.flatMap = zipWith.flatMap;
|
|
|
73
80
|
exports.flatMapDeep = zipWith.flatMapDeep;
|
|
74
81
|
exports.flatten = zipWith.flatten;
|
|
75
82
|
exports.flattenDeep = zipWith.flattenDeep;
|
|
76
|
-
exports.forEachRight = zipWith.forEachRight;
|
|
77
83
|
exports.groupBy = zipWith.groupBy;
|
|
78
84
|
exports.head = zipWith.head;
|
|
79
85
|
exports.initial = zipWith.initial;
|
|
@@ -113,6 +119,7 @@ exports.xorWith = zipWith.xorWith;
|
|
|
113
119
|
exports.zip = zipWith.zip;
|
|
114
120
|
exports.zipObject = zipWith.zipObject;
|
|
115
121
|
exports.zipWith = zipWith.zipWith;
|
|
122
|
+
exports.forEachRight = forEachRight;
|
|
116
123
|
exports.orderBy = orderBy;
|
|
117
124
|
exports.sortBy = sortBy;
|
|
118
125
|
exports.takeRightWhile = takeRightWhile;
|
package/dist/array/take.d.mts
CHANGED
package/dist/array/take.d.ts
CHANGED
package/dist/array/take.mjs
CHANGED
package/dist/array/takeRight.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { toInteger } from '../compat/util/toInteger.mjs';
|
|
2
|
+
|
|
3
|
+
function takeRight(arr, count = 1, guard) {
|
|
4
|
+
count = guard || count === undefined ? 1 : toInteger(count);
|
|
5
|
+
if (count <= 0 || arr == null || arr.length === 0) {
|
|
3
6
|
return [];
|
|
4
7
|
}
|
|
5
8
|
return arr.slice(-count);
|