es-toolkit 1.20.0 → 1.21.0-dev.662
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 +13 -0
- package/dist/_chunk/{isWeakSet-E_VMwB.js → isWeakSet-1xFSnK.js} +5 -0
- package/dist/_chunk/{toMerged-Bzkqyz.js → toMerged-D-sLFv.js} +10 -8
- package/dist/_chunk/{zipWith-CDtN9Y.js → zipWith-DEcUS4.js} +25 -12
- package/dist/array/compact.d.mts +4 -4
- package/dist/array/compact.d.ts +4 -4
- package/dist/array/compact.mjs +2 -1
- package/dist/array/countBy.mjs +2 -1
- package/dist/array/flatten.mjs +2 -1
- package/dist/array/groupBy.mjs +2 -1
- package/dist/array/index.js +1 -1
- package/dist/array/keyBy.mjs +2 -1
- package/dist/array/maxBy.d.mts +16 -0
- package/dist/array/maxBy.d.ts +16 -0
- package/dist/array/maxBy.mjs +2 -1
- package/dist/array/minBy.d.mts +16 -0
- package/dist/array/minBy.d.ts +16 -0
- package/dist/array/minBy.mjs +2 -1
- package/dist/array/partition.mjs +2 -1
- package/dist/array/takeWhile.mjs +2 -1
- package/dist/array/unionBy.mjs +3 -1
- package/dist/array/uniqBy.mjs +2 -1
- package/dist/array/uniqWith.mjs +2 -1
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/castArray.d.mts +2 -2
- package/dist/compat/array/castArray.d.ts +2 -2
- package/dist/compat/array/flatten.mjs +2 -1
- package/dist/compat/function/curry.mjs +26 -34
- package/dist/compat/function/defer.d.mts +16 -0
- package/dist/compat/function/defer.d.ts +16 -0
- package/dist/compat/function/defer.mjs +8 -0
- package/dist/compat/index.d.mts +13 -5
- package/dist/compat/index.d.ts +13 -5
- package/dist/compat/index.js +200 -71
- package/dist/compat/index.mjs +14 -6
- package/dist/compat/math/inRange.d.mts +27 -0
- package/dist/compat/math/inRange.d.ts +27 -0
- package/dist/compat/math/inRange.mjs +28 -0
- package/dist/compat/math/max.mjs +2 -1
- package/dist/compat/math/min.mjs +2 -1
- package/dist/compat/math/random.d.mts +50 -0
- package/dist/compat/math/random.d.ts +50 -0
- package/dist/compat/math/random.mjs +70 -0
- package/dist/compat/object/cloneDeep.d.mts +49 -0
- package/dist/compat/object/cloneDeep.d.ts +49 -0
- package/dist/compat/object/pick.mjs +2 -1
- package/dist/compat/predicate/conformsTo.mjs +3 -1
- package/dist/compat/predicate/isArrayLikeObject.d.mts +15 -0
- package/dist/compat/predicate/isArrayLikeObject.d.ts +15 -0
- package/dist/compat/predicate/isArrayLikeObject.mjs +8 -0
- package/dist/compat/predicate/isBoolean.d.mts +3 -3
- package/dist/compat/predicate/isBoolean.d.ts +3 -3
- package/dist/compat/predicate/isBoolean.mjs +2 -10
- package/dist/compat/predicate/isError.d.mts +16 -0
- package/dist/compat/predicate/isError.d.ts +16 -0
- package/dist/compat/predicate/isError.mjs +7 -0
- package/dist/compat/predicate/isFinite.d.mts +20 -0
- package/dist/compat/predicate/isFinite.d.ts +20 -0
- package/dist/compat/predicate/isFinite.mjs +5 -0
- package/dist/compat/predicate/isNil.d.mts +22 -0
- package/dist/compat/predicate/isNil.d.ts +22 -0
- package/dist/compat/predicate/isNumber.mjs +1 -6
- package/dist/compat/predicate/isRegExp.mjs +2 -2
- package/dist/compat/predicate/isString.d.mts +1 -1
- package/dist/compat/predicate/isString.d.ts +1 -1
- package/dist/compat/predicate/isString.mjs +1 -9
- package/dist/compat/predicate/isSymbol.mjs +1 -1
- package/dist/compat/string/pad.d.mts +19 -0
- package/dist/compat/string/pad.d.ts +19 -0
- package/dist/compat/string/pad.mjs +8 -0
- package/dist/compat/string/padEnd.mjs +3 -1
- package/dist/compat/string/padStart.mjs +3 -1
- package/dist/compat/util/toFinite.d.mts +17 -0
- package/dist/compat/util/toFinite.d.ts +17 -0
- package/dist/compat/util/toFinite.mjs +15 -0
- package/dist/compat/util/toInteger.d.mts +20 -0
- package/dist/compat/util/toInteger.d.ts +20 -0
- package/dist/compat/util/toInteger.mjs +9 -0
- package/dist/compat/util/toNumber.d.mts +19 -0
- package/dist/compat/util/toNumber.d.ts +19 -0
- package/dist/compat/util/toNumber.mjs +10 -0
- package/dist/function/curry.d.mts +18 -19
- package/dist/function/curry.d.ts +18 -19
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10 -8
- package/dist/index.mjs +2 -0
- package/dist/math/random.d.mts +1 -1
- package/dist/math/random.d.ts +1 -1
- package/dist/math/range.d.mts +7 -25
- package/dist/math/range.d.ts +7 -25
- package/dist/object/index.js +8 -4
- package/dist/object/omit.d.mts +1 -1
- package/dist/object/omit.d.ts +1 -1
- package/dist/object/omit.mjs +2 -1
- package/dist/object/omitBy.mjs +5 -4
- package/dist/object/pick.mjs +5 -2
- package/dist/object/pickBy.mjs +5 -4
- package/dist/predicate/index.d.mts +1 -0
- package/dist/predicate/index.d.ts +1 -0
- package/dist/predicate/index.js +5 -4
- package/dist/predicate/index.mjs +1 -0
- package/dist/predicate/isError.d.mts +16 -0
- package/dist/predicate/isError.d.ts +16 -0
- package/dist/predicate/isError.mjs +5 -0
- package/dist/promise/withTimeout.d.mts +8 -2
- package/dist/promise/withTimeout.d.ts +8 -2
- package/dist/string/_internal/getWords.mjs +1 -1
- package/dist/string/camelCase.d.mts +1 -0
- package/dist/string/camelCase.d.ts +1 -0
- package/dist/string/constantCase.d.mts +17 -0
- package/dist/string/constantCase.d.ts +17 -0
- package/dist/string/constantCase.mjs +8 -0
- package/dist/string/index.d.mts +1 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.js +10 -8
- package/dist/string/index.mjs +1 -0
- package/dist/string/startCase.d.mts +1 -1
- package/dist/string/startCase.d.ts +1 -1
- package/dist/string/startCase.mjs +3 -7
- package/dist/string/trimStart.d.mts +1 -1
- package/dist/string/trimStart.d.ts +1 -1
- package/dist/string/upperFirst.d.mts +3 -3
- package/dist/string/upperFirst.d.ts +3 -3
- package/package.json +2 -1
package/dist/compat/index.js
CHANGED
|
@@ -2,14 +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-DEcUS4.js');
|
|
6
6
|
const promise_index = require('../_chunk/index-BGZDR9.js');
|
|
7
7
|
const rest$1 = require('../_chunk/rest-pUyjvl.js');
|
|
8
8
|
const range = require('../_chunk/range-BXlMmn.js');
|
|
9
9
|
const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
10
|
-
const toMerged = require('../_chunk/toMerged-
|
|
11
|
-
const isWeakSet$1 = require('../_chunk/isWeakSet-E_VMwB.js');
|
|
10
|
+
const toMerged = require('../_chunk/toMerged-D-sLFv.js');
|
|
12
11
|
const isPlainObject$1 = require('../_chunk/isPlainObject-BIekvL.js');
|
|
12
|
+
const isWeakSet$1 = require('../_chunk/isWeakSet-1xFSnK.js');
|
|
13
13
|
const string_index = require('../string/index.js');
|
|
14
14
|
|
|
15
15
|
function castArray(value) {
|
|
@@ -473,7 +473,8 @@ function flatten(value, depth = 1) {
|
|
|
473
473
|
return result;
|
|
474
474
|
}
|
|
475
475
|
const recursive = (arr, currentDepth) => {
|
|
476
|
-
for (
|
|
476
|
+
for (let i = 0; i < arr.length; i++) {
|
|
477
|
+
const item = arr[i];
|
|
477
478
|
if (currentDepth < flooredDepth &&
|
|
478
479
|
(Array.isArray(item) ||
|
|
479
480
|
Boolean(item?.[Symbol.isConcatSpreadable]) ||
|
|
@@ -561,7 +562,7 @@ const compareValues = (a, b, order) => {
|
|
|
561
562
|
};
|
|
562
563
|
|
|
563
564
|
function isSymbol(value) {
|
|
564
|
-
return typeof value === 'symbol' ||
|
|
565
|
+
return typeof value === 'symbol' || value instanceof Symbol;
|
|
565
566
|
}
|
|
566
567
|
|
|
567
568
|
const regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
@@ -784,6 +785,13 @@ function bindKey(object, key, ...partialArgs) {
|
|
|
784
785
|
const bindKeyPlaceholder = Symbol('bindKey.placeholder');
|
|
785
786
|
bindKey.placeholder = bindKeyPlaceholder;
|
|
786
787
|
|
|
788
|
+
function defer(func, ...args) {
|
|
789
|
+
if (typeof func !== 'function') {
|
|
790
|
+
throw new TypeError('Expected a function');
|
|
791
|
+
}
|
|
792
|
+
return setTimeout(func, 1, ...args);
|
|
793
|
+
}
|
|
794
|
+
|
|
787
795
|
function rest(func, start = func.length - 1) {
|
|
788
796
|
start = Number.parseInt(start, 10);
|
|
789
797
|
if (Number.isNaN(start) || start < 0) {
|
|
@@ -833,60 +841,52 @@ function curry(func, arity = func.length, guard) {
|
|
|
833
841
|
if (Number.isNaN(arity) || arity < 1) {
|
|
834
842
|
arity = 0;
|
|
835
843
|
}
|
|
836
|
-
const wrapper = function (...
|
|
837
|
-
const holders =
|
|
838
|
-
const length =
|
|
844
|
+
const wrapper = function (...partialArgs) {
|
|
845
|
+
const holders = partialArgs.filter(item => item === curry.placeholder);
|
|
846
|
+
const length = partialArgs.length - holders.length;
|
|
839
847
|
if (length < arity) {
|
|
840
|
-
return makeCurry(func,
|
|
848
|
+
return makeCurry(func, arity - length, partialArgs);
|
|
841
849
|
}
|
|
842
850
|
if (this instanceof wrapper) {
|
|
843
|
-
return new func(...
|
|
851
|
+
return new func(...partialArgs);
|
|
844
852
|
}
|
|
845
|
-
return func.apply(this,
|
|
853
|
+
return func.apply(this, partialArgs);
|
|
846
854
|
};
|
|
847
855
|
wrapper.placeholder = curryPlaceholder;
|
|
848
856
|
return wrapper;
|
|
849
857
|
}
|
|
850
|
-
function makeCurry(func,
|
|
851
|
-
function wrapper(...
|
|
852
|
-
const
|
|
853
|
-
const length =
|
|
854
|
-
|
|
858
|
+
function makeCurry(func, arity, partialArgs) {
|
|
859
|
+
function wrapper(...providedArgs) {
|
|
860
|
+
const holders = providedArgs.filter(item => item === curry.placeholder);
|
|
861
|
+
const length = providedArgs.length - holders.length;
|
|
862
|
+
providedArgs = composeArgs(providedArgs, partialArgs);
|
|
855
863
|
if (length < arity) {
|
|
856
|
-
|
|
857
|
-
return makeCurry(func, newHolders, arity - length, args);
|
|
864
|
+
return makeCurry(func, arity - length, providedArgs);
|
|
858
865
|
}
|
|
859
866
|
if (this instanceof wrapper) {
|
|
860
|
-
return new func(...
|
|
867
|
+
return new func(...providedArgs);
|
|
861
868
|
}
|
|
862
|
-
return func.apply(this,
|
|
869
|
+
return func.apply(this, providedArgs);
|
|
863
870
|
}
|
|
864
871
|
wrapper.placeholder = curryPlaceholder;
|
|
865
872
|
return wrapper;
|
|
866
873
|
}
|
|
867
|
-
function
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
874
|
+
function composeArgs(providedArgs, partialArgs) {
|
|
875
|
+
const args = [];
|
|
876
|
+
let startIndex = 0;
|
|
877
|
+
for (let i = 0; i < partialArgs.length; i++) {
|
|
878
|
+
const arg = partialArgs[i];
|
|
879
|
+
if (arg === curry.placeholder && startIndex < providedArgs.length) {
|
|
880
|
+
args.push(providedArgs[startIndex++]);
|
|
872
881
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
}
|
|
876
|
-
function composeArgs(args, partials, holders) {
|
|
877
|
-
const result = [...partials];
|
|
878
|
-
const argsLength = args.length;
|
|
879
|
-
const holdersLength = holders.length;
|
|
880
|
-
let argsIndex = -1, leftIndex = partials.length, rangeLength = Math.max(argsLength - holdersLength, 0);
|
|
881
|
-
while (++argsIndex < holdersLength) {
|
|
882
|
-
if (argsIndex < argsLength) {
|
|
883
|
-
result[holders[argsIndex]] = args[argsIndex];
|
|
882
|
+
else {
|
|
883
|
+
args.push(arg);
|
|
884
884
|
}
|
|
885
885
|
}
|
|
886
|
-
|
|
887
|
-
|
|
886
|
+
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
887
|
+
args.push(providedArgs[i]);
|
|
888
888
|
}
|
|
889
|
-
return
|
|
889
|
+
return args;
|
|
890
890
|
}
|
|
891
891
|
const curryPlaceholder = Symbol('curry.placeholder');
|
|
892
892
|
curry.placeholder = curryPlaceholder;
|
|
@@ -953,7 +953,8 @@ function pick(obj, ...keysArr) {
|
|
|
953
953
|
return {};
|
|
954
954
|
}
|
|
955
955
|
const result = {};
|
|
956
|
-
for (let
|
|
956
|
+
for (let i = 0; i < keysArr.length; i++) {
|
|
957
|
+
let keys = keysArr[i];
|
|
957
958
|
switch (typeof keys) {
|
|
958
959
|
case 'object': {
|
|
959
960
|
if (!Array.isArray(keys)) {
|
|
@@ -1236,28 +1237,24 @@ function isObject(value) {
|
|
|
1236
1237
|
return value !== null && (typeof value === 'object' || typeof value === 'function');
|
|
1237
1238
|
}
|
|
1238
1239
|
|
|
1239
|
-
function isBoolean(
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1240
|
+
function isBoolean(value) {
|
|
1241
|
+
return typeof value === 'boolean' || value instanceof Boolean;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
function isError(value) {
|
|
1245
|
+
return isWeakSet$1.getTag(value) === '[object Error]';
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
function isFinite(value) {
|
|
1249
|
+
return Number.isFinite(value);
|
|
1247
1250
|
}
|
|
1248
1251
|
|
|
1249
1252
|
function isRegExp(value) {
|
|
1250
|
-
return isWeakSet$1.
|
|
1253
|
+
return isWeakSet$1.isRegExp(value);
|
|
1251
1254
|
}
|
|
1252
1255
|
|
|
1253
1256
|
function isString(value) {
|
|
1254
|
-
|
|
1255
|
-
return true;
|
|
1256
|
-
}
|
|
1257
|
-
if (typeof value === 'object' && value != null && isWeakSet$1.getTag(value) === '[object String]') {
|
|
1258
|
-
return true;
|
|
1259
|
-
}
|
|
1260
|
-
return false;
|
|
1257
|
+
return typeof value === 'string' || value instanceof String;
|
|
1261
1258
|
}
|
|
1262
1259
|
|
|
1263
1260
|
function isWeakMap(value) {
|
|
@@ -1275,7 +1272,9 @@ function conformsTo(target, source) {
|
|
|
1275
1272
|
if (target == null) {
|
|
1276
1273
|
return Object.keys(source).length === 0;
|
|
1277
1274
|
}
|
|
1278
|
-
|
|
1275
|
+
const keys = Object.keys(source);
|
|
1276
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1277
|
+
const key = keys[i];
|
|
1279
1278
|
const predicate = source[key];
|
|
1280
1279
|
const value = target[key];
|
|
1281
1280
|
if ((value === undefined && !(key in target)) || !predicate(value)) {
|
|
@@ -1301,16 +1300,17 @@ function isSafeInteger(value) {
|
|
|
1301
1300
|
}
|
|
1302
1301
|
|
|
1303
1302
|
function isNumber(value) {
|
|
1304
|
-
|
|
1305
|
-
return true;
|
|
1306
|
-
}
|
|
1307
|
-
return typeof value === 'number';
|
|
1303
|
+
return typeof value === 'number' || value instanceof Number;
|
|
1308
1304
|
}
|
|
1309
1305
|
|
|
1310
1306
|
function isNaN(value) {
|
|
1311
1307
|
return Number.isNaN(value);
|
|
1312
1308
|
}
|
|
1313
1309
|
|
|
1310
|
+
function isArrayLikeObject(value) {
|
|
1311
|
+
return toMerged.isObjectLike(value) && isArrayLike(value);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
1314
|
function toString(value) {
|
|
1315
1315
|
if (value == null) {
|
|
1316
1316
|
return '';
|
|
@@ -1364,12 +1364,16 @@ function endsWith(str, target, position = str.length) {
|
|
|
1364
1364
|
return str.endsWith(target, position);
|
|
1365
1365
|
}
|
|
1366
1366
|
|
|
1367
|
+
function pad(str, length, chars = ' ') {
|
|
1368
|
+
return string_index.pad(toString(str), length, chars);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1367
1371
|
function padStart(str, length = 0, chars = ' ') {
|
|
1368
|
-
return str.padStart(length, chars);
|
|
1372
|
+
return toString(str).padStart(length, chars);
|
|
1369
1373
|
}
|
|
1370
1374
|
|
|
1371
1375
|
function padEnd(str, length = 0, chars = ' ') {
|
|
1372
|
-
return str.padEnd(length, chars);
|
|
1376
|
+
return toString(str).padEnd(length, chars);
|
|
1373
1377
|
}
|
|
1374
1378
|
|
|
1375
1379
|
function repeat(str, n) {
|
|
@@ -1455,7 +1459,8 @@ function clamp(value, bound1, bound2) {
|
|
|
1455
1459
|
function max(items = []) {
|
|
1456
1460
|
let maxElement = items[0];
|
|
1457
1461
|
let max = undefined;
|
|
1458
|
-
for (
|
|
1462
|
+
for (let i = 0; i < items.length; i++) {
|
|
1463
|
+
const element = items[i];
|
|
1459
1464
|
if (max == null || element > max) {
|
|
1460
1465
|
max = element;
|
|
1461
1466
|
maxElement = element;
|
|
@@ -1467,7 +1472,8 @@ function max(items = []) {
|
|
|
1467
1472
|
function min(items = []) {
|
|
1468
1473
|
let minElement = items[0];
|
|
1469
1474
|
let min = undefined;
|
|
1470
|
-
for (
|
|
1475
|
+
for (let i = 0; i < items.length; i++) {
|
|
1476
|
+
const element = items[i];
|
|
1471
1477
|
if (min == null || element < min) {
|
|
1472
1478
|
min = element;
|
|
1473
1479
|
minElement = element;
|
|
@@ -1513,6 +1519,121 @@ function parseInt(string, radix = 0, guard) {
|
|
|
1513
1519
|
return Number.parseInt(string, radix);
|
|
1514
1520
|
}
|
|
1515
1521
|
|
|
1522
|
+
function inRange(value, minimum, maximum) {
|
|
1523
|
+
if (!minimum) {
|
|
1524
|
+
minimum = 0;
|
|
1525
|
+
}
|
|
1526
|
+
if (maximum != null && !maximum) {
|
|
1527
|
+
maximum = 0;
|
|
1528
|
+
}
|
|
1529
|
+
if (minimum != null && typeof minimum !== 'number') {
|
|
1530
|
+
minimum = Number(minimum);
|
|
1531
|
+
}
|
|
1532
|
+
if (maximum == null && minimum === 0) {
|
|
1533
|
+
return false;
|
|
1534
|
+
}
|
|
1535
|
+
if (maximum != null && typeof maximum !== 'number') {
|
|
1536
|
+
maximum = Number(maximum);
|
|
1537
|
+
}
|
|
1538
|
+
if (maximum != null && minimum > maximum) {
|
|
1539
|
+
[minimum, maximum] = [maximum, minimum];
|
|
1540
|
+
}
|
|
1541
|
+
if (minimum === maximum) {
|
|
1542
|
+
return false;
|
|
1543
|
+
}
|
|
1544
|
+
return range.inRange(value, minimum, maximum);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
function random(...args) {
|
|
1548
|
+
let minimum = 0;
|
|
1549
|
+
let maximum = 1;
|
|
1550
|
+
let floating = false;
|
|
1551
|
+
switch (args.length) {
|
|
1552
|
+
case 1: {
|
|
1553
|
+
if (typeof args[0] === 'boolean') {
|
|
1554
|
+
floating = args[0];
|
|
1555
|
+
}
|
|
1556
|
+
else {
|
|
1557
|
+
maximum = args[0];
|
|
1558
|
+
}
|
|
1559
|
+
break;
|
|
1560
|
+
}
|
|
1561
|
+
case 2: {
|
|
1562
|
+
if (typeof args[1] === 'boolean') {
|
|
1563
|
+
maximum = args[0];
|
|
1564
|
+
floating = args[1];
|
|
1565
|
+
}
|
|
1566
|
+
else {
|
|
1567
|
+
minimum = args[0];
|
|
1568
|
+
maximum = args[1];
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
case 3: {
|
|
1572
|
+
if (typeof args[2] === 'object' && args[2] != null && args[2][args[1]] === args[0]) {
|
|
1573
|
+
minimum = 0;
|
|
1574
|
+
maximum = args[0];
|
|
1575
|
+
floating = false;
|
|
1576
|
+
}
|
|
1577
|
+
else {
|
|
1578
|
+
minimum = args[0];
|
|
1579
|
+
maximum = args[1];
|
|
1580
|
+
floating = args[2];
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
if (typeof minimum !== 'number') {
|
|
1585
|
+
minimum = Number(minimum);
|
|
1586
|
+
}
|
|
1587
|
+
if (typeof maximum !== 'number') {
|
|
1588
|
+
minimum = Number(maximum);
|
|
1589
|
+
}
|
|
1590
|
+
if (!minimum) {
|
|
1591
|
+
minimum = 0;
|
|
1592
|
+
}
|
|
1593
|
+
if (!maximum) {
|
|
1594
|
+
maximum = 0;
|
|
1595
|
+
}
|
|
1596
|
+
if (minimum > maximum) {
|
|
1597
|
+
[minimum, maximum] = [maximum, minimum];
|
|
1598
|
+
}
|
|
1599
|
+
minimum = clamp(minimum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
1600
|
+
maximum = clamp(maximum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
1601
|
+
if (minimum === maximum) {
|
|
1602
|
+
return minimum;
|
|
1603
|
+
}
|
|
1604
|
+
if (floating) {
|
|
1605
|
+
return randomInt.random(minimum, maximum + 1);
|
|
1606
|
+
}
|
|
1607
|
+
else {
|
|
1608
|
+
return randomInt.randomInt(minimum, maximum + 1);
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
function toNumber(value) {
|
|
1613
|
+
if (isSymbol(value)) {
|
|
1614
|
+
return NaN;
|
|
1615
|
+
}
|
|
1616
|
+
return Number(value);
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
function toFinite(value) {
|
|
1620
|
+
if (!value) {
|
|
1621
|
+
return value === 0 ? value : 0;
|
|
1622
|
+
}
|
|
1623
|
+
value = toNumber(value);
|
|
1624
|
+
if (value === Infinity || value === -Infinity) {
|
|
1625
|
+
const sign = value < 0 ? -1 : 1;
|
|
1626
|
+
return sign * Number.MAX_VALUE;
|
|
1627
|
+
}
|
|
1628
|
+
return value === value ? value : 0;
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
function toInteger(value) {
|
|
1632
|
+
const finite = toFinite(value);
|
|
1633
|
+
const remainder = finite % 1;
|
|
1634
|
+
return remainder ? finite - remainder : finite;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1516
1637
|
exports.at = zipWith.at;
|
|
1517
1638
|
exports.compact = zipWith.compact;
|
|
1518
1639
|
exports.countBy = zipWith.countBy;
|
|
@@ -1576,37 +1697,33 @@ exports.once = rest$1.once;
|
|
|
1576
1697
|
exports.partial = rest$1.partial;
|
|
1577
1698
|
exports.partialRight = rest$1.partialRight;
|
|
1578
1699
|
exports.unary = rest$1.unary;
|
|
1579
|
-
exports.inRange = range.inRange;
|
|
1580
1700
|
exports.mean = range.mean;
|
|
1581
1701
|
exports.meanBy = range.meanBy;
|
|
1582
1702
|
exports.range = range.range;
|
|
1583
1703
|
exports.sum = range.sum;
|
|
1584
1704
|
exports.sumBy = range.sumBy;
|
|
1585
|
-
exports.random = randomInt.random;
|
|
1586
1705
|
exports.randomInt = randomInt.randomInt;
|
|
1587
1706
|
exports.clone = toMerged.clone;
|
|
1588
|
-
exports.cloneDeep = toMerged.cloneDeep;
|
|
1589
1707
|
exports.flattenObject = toMerged.flattenObject;
|
|
1590
1708
|
exports.invert = toMerged.invert;
|
|
1591
1709
|
exports.isObjectLike = toMerged.isObjectLike;
|
|
1592
1710
|
exports.omitBy = toMerged.omitBy;
|
|
1593
1711
|
exports.pickBy = toMerged.pickBy;
|
|
1594
1712
|
exports.toMerged = toMerged.toMerged;
|
|
1713
|
+
exports.isPrimitive = isPlainObject$1.isPrimitive;
|
|
1595
1714
|
exports.isDate = isWeakSet$1.isDate;
|
|
1596
1715
|
exports.isEqual = isWeakSet$1.isEqual;
|
|
1597
1716
|
exports.isFunction = isWeakSet$1.isFunction;
|
|
1598
1717
|
exports.isLength = isWeakSet$1.isLength;
|
|
1599
|
-
exports.isNil = isWeakSet$1.isNil;
|
|
1600
1718
|
exports.isNotNil = isWeakSet$1.isNotNil;
|
|
1601
1719
|
exports.isNull = isWeakSet$1.isNull;
|
|
1602
1720
|
exports.isUndefined = isWeakSet$1.isUndefined;
|
|
1603
|
-
exports.isPrimitive = isPlainObject$1.isPrimitive;
|
|
1604
1721
|
exports.capitalize = string_index.capitalize;
|
|
1722
|
+
exports.constantCase = string_index.constantCase;
|
|
1605
1723
|
exports.deburr = string_index.deburr;
|
|
1606
1724
|
exports.escape = string_index.escape;
|
|
1607
1725
|
exports.escapeRegExp = string_index.escapeRegExp;
|
|
1608
1726
|
exports.lowerFirst = string_index.lowerFirst;
|
|
1609
|
-
exports.pad = string_index.pad;
|
|
1610
1727
|
exports.pascalCase = string_index.pascalCase;
|
|
1611
1728
|
exports.unescape = string_index.unescape;
|
|
1612
1729
|
exports.upperFirst = string_index.upperFirst;
|
|
@@ -1619,11 +1736,13 @@ exports.castArray = castArray;
|
|
|
1619
1736
|
exports.ceil = ceil;
|
|
1620
1737
|
exports.chunk = chunk;
|
|
1621
1738
|
exports.clamp = clamp;
|
|
1739
|
+
exports.cloneDeep = cloneDeep;
|
|
1622
1740
|
exports.concat = concat;
|
|
1623
1741
|
exports.conforms = conforms;
|
|
1624
1742
|
exports.conformsTo = conformsTo;
|
|
1625
1743
|
exports.curry = curry;
|
|
1626
1744
|
exports.debounce = debounce;
|
|
1745
|
+
exports.defer = defer;
|
|
1627
1746
|
exports.difference = difference;
|
|
1628
1747
|
exports.drop = drop;
|
|
1629
1748
|
exports.endsWith = endsWith;
|
|
@@ -1638,14 +1757,19 @@ exports.floor = floor;
|
|
|
1638
1757
|
exports.fromPairs = fromPairs;
|
|
1639
1758
|
exports.get = get;
|
|
1640
1759
|
exports.has = has;
|
|
1760
|
+
exports.inRange = inRange;
|
|
1641
1761
|
exports.indexOf = indexOf;
|
|
1642
1762
|
exports.isArguments = isArguments;
|
|
1643
1763
|
exports.isArray = isArray;
|
|
1644
1764
|
exports.isArrayLike = isArrayLike;
|
|
1765
|
+
exports.isArrayLikeObject = isArrayLikeObject;
|
|
1645
1766
|
exports.isBoolean = isBoolean;
|
|
1767
|
+
exports.isError = isError;
|
|
1768
|
+
exports.isFinite = isFinite;
|
|
1646
1769
|
exports.isInteger = isInteger;
|
|
1647
1770
|
exports.isMatch = isMatch;
|
|
1648
1771
|
exports.isNaN = isNaN;
|
|
1772
|
+
exports.isNil = isNil;
|
|
1649
1773
|
exports.isNumber = isNumber;
|
|
1650
1774
|
exports.isObject = isObject;
|
|
1651
1775
|
exports.isPlainObject = isPlainObject;
|
|
@@ -1669,11 +1793,13 @@ exports.mergeWith = mergeWith;
|
|
|
1669
1793
|
exports.min = min;
|
|
1670
1794
|
exports.omit = omit;
|
|
1671
1795
|
exports.orderBy = orderBy;
|
|
1796
|
+
exports.pad = pad;
|
|
1672
1797
|
exports.padEnd = padEnd;
|
|
1673
1798
|
exports.padStart = padStart;
|
|
1674
1799
|
exports.parseInt = parseInt;
|
|
1675
1800
|
exports.pick = pick;
|
|
1676
1801
|
exports.property = property;
|
|
1802
|
+
exports.random = random;
|
|
1677
1803
|
exports.rearg = rearg;
|
|
1678
1804
|
exports.repeat = repeat;
|
|
1679
1805
|
exports.rest = rest;
|
|
@@ -1687,6 +1813,9 @@ exports.spread = spread;
|
|
|
1687
1813
|
exports.startCase = startCase;
|
|
1688
1814
|
exports.startsWith = startsWith;
|
|
1689
1815
|
exports.throttle = throttle;
|
|
1816
|
+
exports.toFinite = toFinite;
|
|
1817
|
+
exports.toInteger = toInteger;
|
|
1818
|
+
exports.toNumber = toNumber;
|
|
1690
1819
|
exports.toPath = toPath;
|
|
1691
1820
|
exports.toString = toString;
|
|
1692
1821
|
exports.trim = trim;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -57,10 +57,8 @@ export { memoize } from '../function/memoize.mjs';
|
|
|
57
57
|
export { unary } from '../function/unary.mjs';
|
|
58
58
|
export { partial } from '../function/partial.mjs';
|
|
59
59
|
export { partialRight } from '../function/partialRight.mjs';
|
|
60
|
-
export { inRange } from '../math/inRange.mjs';
|
|
61
60
|
export { mean } from '../math/mean.mjs';
|
|
62
61
|
export { meanBy } from '../math/meanBy.mjs';
|
|
63
|
-
export { random } from '../math/random.mjs';
|
|
64
62
|
export { randomInt } from '../math/randomInt.mjs';
|
|
65
63
|
export { sum } from '../math/sum.mjs';
|
|
66
64
|
export { sumBy } from '../math/sumBy.mjs';
|
|
@@ -70,30 +68,28 @@ export { pickBy } from '../object/pickBy.mjs';
|
|
|
70
68
|
export { invert } from '../object/invert.mjs';
|
|
71
69
|
export { clone } from '../object/clone.mjs';
|
|
72
70
|
export { flattenObject } from '../object/flattenObject.mjs';
|
|
73
|
-
export {
|
|
71
|
+
export { isPrimitive } from '../predicate/isPrimitive.mjs';
|
|
74
72
|
export { isObjectLike } from './predicate/isObjectLike.mjs';
|
|
75
73
|
export { toMerged } from '../object/toMerged.mjs';
|
|
76
74
|
export { isDate } from '../predicate/isDate.mjs';
|
|
77
75
|
export { isEqual } from '../predicate/isEqual.mjs';
|
|
78
|
-
export { isNil } from '../predicate/isNil.mjs';
|
|
79
76
|
export { isNotNil } from '../predicate/isNotNil.mjs';
|
|
80
77
|
export { isNull } from '../predicate/isNull.mjs';
|
|
81
78
|
export { isUndefined } from '../predicate/isUndefined.mjs';
|
|
82
79
|
export { isLength } from '../predicate/isLength.mjs';
|
|
83
80
|
export { isFunction } from '../predicate/isFunction.mjs';
|
|
84
|
-
export { isPrimitive } from '../predicate/isPrimitive.mjs';
|
|
85
81
|
export { delay } from '../promise/delay.mjs';
|
|
86
82
|
export { withTimeout } from '../promise/withTimeout.mjs';
|
|
87
83
|
export { timeout } from '../promise/timeout.mjs';
|
|
88
84
|
export { capitalize } from '../string/capitalize.mjs';
|
|
89
85
|
export { pascalCase } from '../string/pascalCase.mjs';
|
|
86
|
+
export { constantCase } from '../string/constantCase.mjs';
|
|
90
87
|
export { upperFirst } from '../string/upperFirst.mjs';
|
|
91
88
|
export { lowerFirst } from '../string/lowerFirst.mjs';
|
|
92
89
|
export { deburr } from '../string/deburr.mjs';
|
|
93
90
|
export { escape } from '../string/escape.mjs';
|
|
94
91
|
export { escapeRegExp } from '../string/escapeRegExp.mjs';
|
|
95
92
|
export { unescape } from '../string/unescape.mjs';
|
|
96
|
-
export { pad } from '../string/pad.mjs';
|
|
97
93
|
export { castArray } from './array/castArray.mjs';
|
|
98
94
|
export { chunk } from './array/chunk.mjs';
|
|
99
95
|
export { concat } from './array/concat.mjs';
|
|
@@ -116,6 +112,7 @@ export { zipObjectDeep } from './array/zipObjectDeep.mjs';
|
|
|
116
112
|
export { ary } from './function/ary.mjs';
|
|
117
113
|
export { bind } from './function/bind.mjs';
|
|
118
114
|
export { bindKey } from './function/bindKey.mjs';
|
|
115
|
+
export { defer } from './function/defer.mjs';
|
|
119
116
|
export { rest } from './function/rest.mjs';
|
|
120
117
|
export { spread } from './function/spread.mjs';
|
|
121
118
|
export { attempt } from './function/attempt.mjs';
|
|
@@ -135,6 +132,7 @@ export { merge } from './object/merge.mjs';
|
|
|
135
132
|
export { mergeWith } from './object/mergeWith.mjs';
|
|
136
133
|
export { fromPairs } from './object/fromPairs.mjs';
|
|
137
134
|
export { unset } from './object/unset.mjs';
|
|
135
|
+
export { cloneDeep } from './object/cloneDeep.mjs';
|
|
138
136
|
export { isPlainObject } from './predicate/isPlainObject.mjs';
|
|
139
137
|
export { isArray } from './predicate/isArray.mjs';
|
|
140
138
|
export { isArguments } from './predicate/isArguments.mjs';
|
|
@@ -142,6 +140,8 @@ export { isArrayLike } from './predicate/isArrayLike.mjs';
|
|
|
142
140
|
export { isSymbol } from './predicate/isSymbol.mjs';
|
|
143
141
|
export { isObject } from './predicate/isObject.mjs';
|
|
144
142
|
export { isBoolean } from './predicate/isBoolean.mjs';
|
|
143
|
+
export { isError } from './predicate/isError.mjs';
|
|
144
|
+
export { isFinite } from './predicate/isFinite.mjs';
|
|
145
145
|
export { isTypedArray } from './predicate/isTypedArray.mjs';
|
|
146
146
|
export { isMatch } from './predicate/isMatch.mjs';
|
|
147
147
|
export { isRegExp } from './predicate/isRegExp.mjs';
|
|
@@ -156,6 +156,8 @@ export { isInteger } from './predicate/isInteger.mjs';
|
|
|
156
156
|
export { isSafeInteger } from './predicate/isSafeInteger.mjs';
|
|
157
157
|
export { isNumber } from './predicate/isNumber.mjs';
|
|
158
158
|
export { isNaN } from './predicate/isNaN.mjs';
|
|
159
|
+
export { isArrayLikeObject } from './predicate/isArrayLikeObject.mjs';
|
|
160
|
+
export { isNil } from './predicate/isNil.mjs';
|
|
159
161
|
export { camelCase } from './string/camelCase.mjs';
|
|
160
162
|
export { kebabCase } from './string/kebabCase.mjs';
|
|
161
163
|
export { snakeCase } from './string/snakeCase.mjs';
|
|
@@ -164,6 +166,7 @@ export { lowerCase } from './string/lowerCase.mjs';
|
|
|
164
166
|
export { upperCase } from './string/upperCase.mjs';
|
|
165
167
|
export { startsWith } from './string/startsWith.mjs';
|
|
166
168
|
export { endsWith } from './string/endsWith.mjs';
|
|
169
|
+
export { pad } from './string/pad.mjs';
|
|
167
170
|
export { padStart } from './string/padStart.mjs';
|
|
168
171
|
export { padEnd } from './string/padEnd.mjs';
|
|
169
172
|
export { repeat } from './string/repeat.mjs';
|
|
@@ -177,5 +180,10 @@ export { ceil } from './math/ceil.mjs';
|
|
|
177
180
|
export { floor } from './math/floor.mjs';
|
|
178
181
|
export { round } from './math/round.mjs';
|
|
179
182
|
export { parseInt } from './math/parseInt.mjs';
|
|
183
|
+
export { inRange } from './math/inRange.mjs';
|
|
184
|
+
export { random } from './math/random.mjs';
|
|
180
185
|
export { toPath } from './util/toPath.mjs';
|
|
181
186
|
export { toString } from './util/toString.mjs';
|
|
187
|
+
export { toNumber } from './util/toNumber.mjs';
|
|
188
|
+
export { toInteger } from './util/toInteger.mjs';
|
|
189
|
+
export { toFinite } from './util/toFinite.mjs';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the value is less than the maximum.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} value The value to check.
|
|
5
|
+
* @param {number} maximum The upper bound of the range (exclusive).
|
|
6
|
+
* @returns {boolean} `true` if the value is less than the maximum, otherwise `false`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const result = inRange(3, 5); // result will be true.
|
|
10
|
+
* const result2 = inRange(5, 5); // result2 will be false.
|
|
11
|
+
*/
|
|
12
|
+
declare function inRange(value: number, maximum: number): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the value is within the range defined by minimum (inclusive) and maximum (exclusive).
|
|
15
|
+
*
|
|
16
|
+
* @param {number} value The value to check.
|
|
17
|
+
* @param {number} minimum The lower bound of the range (inclusive).
|
|
18
|
+
* @param {number} maximum The upper bound of the range (exclusive).
|
|
19
|
+
* @returns {boolean} `true` if the value is within the specified range, otherwise `false`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const result = inRange(3, 2, 5); // result will be true.
|
|
23
|
+
* const result2 = inRange(1, 2, 5); // result2 will be false.
|
|
24
|
+
*/
|
|
25
|
+
declare function inRange(value: number, minimum: number, maximum: number): boolean;
|
|
26
|
+
|
|
27
|
+
export { inRange };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the value is less than the maximum.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} value The value to check.
|
|
5
|
+
* @param {number} maximum The upper bound of the range (exclusive).
|
|
6
|
+
* @returns {boolean} `true` if the value is less than the maximum, otherwise `false`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const result = inRange(3, 5); // result will be true.
|
|
10
|
+
* const result2 = inRange(5, 5); // result2 will be false.
|
|
11
|
+
*/
|
|
12
|
+
declare function inRange(value: number, maximum: number): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the value is within the range defined by minimum (inclusive) and maximum (exclusive).
|
|
15
|
+
*
|
|
16
|
+
* @param {number} value The value to check.
|
|
17
|
+
* @param {number} minimum The lower bound of the range (inclusive).
|
|
18
|
+
* @param {number} maximum The upper bound of the range (exclusive).
|
|
19
|
+
* @returns {boolean} `true` if the value is within the specified range, otherwise `false`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const result = inRange(3, 2, 5); // result will be true.
|
|
23
|
+
* const result2 = inRange(1, 2, 5); // result2 will be false.
|
|
24
|
+
*/
|
|
25
|
+
declare function inRange(value: number, minimum: number, maximum: number): boolean;
|
|
26
|
+
|
|
27
|
+
export { inRange };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { inRange as inRange$1 } from '../../math/inRange.mjs';
|
|
2
|
+
|
|
3
|
+
function inRange(value, minimum, maximum) {
|
|
4
|
+
if (!minimum) {
|
|
5
|
+
minimum = 0;
|
|
6
|
+
}
|
|
7
|
+
if (maximum != null && !maximum) {
|
|
8
|
+
maximum = 0;
|
|
9
|
+
}
|
|
10
|
+
if (minimum != null && typeof minimum !== 'number') {
|
|
11
|
+
minimum = Number(minimum);
|
|
12
|
+
}
|
|
13
|
+
if (maximum == null && minimum === 0) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (maximum != null && typeof maximum !== 'number') {
|
|
17
|
+
maximum = Number(maximum);
|
|
18
|
+
}
|
|
19
|
+
if (maximum != null && minimum > maximum) {
|
|
20
|
+
[minimum, maximum] = [maximum, minimum];
|
|
21
|
+
}
|
|
22
|
+
if (minimum === maximum) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return inRange$1(value, minimum, maximum);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { inRange };
|
package/dist/compat/math/max.mjs
CHANGED
package/dist/compat/math/min.mjs
CHANGED