es-toolkit 1.23.0 → 1.24.0-dev.766
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 +9 -0
- package/README.md +1 -1
- package/dist/_chunk/{isWeakSet-BAMm2l.js → isWeakSet-Bd6nry.js} +59 -46
- package/dist/_chunk/{range-BXlMmn.js → sumBy-BkErWJ.js} +25 -5
- package/dist/_chunk/{isObjectLike-aywuSF.js → toMerged-DDLv0D.js} +88 -86
- package/dist/_chunk/{flowRight-Dv8J0U.js → unary-BZ5Ixo.js} +27 -64
- package/dist/_chunk/{zipWith-EOU_KZ.js → zipWith-wpjySR.js} +8 -17
- package/dist/array/dropRightWhile.d.mts +2 -2
- package/dist/array/dropRightWhile.d.ts +2 -2
- package/dist/array/dropRightWhile.mjs +1 -1
- package/dist/array/dropWhile.d.mts +1 -1
- package/dist/array/dropWhile.d.ts +1 -1
- package/dist/array/index.js +1 -1
- package/dist/array/unionBy.mjs +3 -10
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/_internal/MAX_ARRAY_LENGTH.mjs +3 -0
- package/dist/compat/_internal/isIterateeCall.mjs +17 -0
- package/dist/compat/array/difference.d.mts +9 -3
- package/dist/compat/array/difference.d.ts +9 -3
- package/dist/compat/array/difference.mjs +12 -3
- package/dist/compat/array/dropRightWhile.d.mts +60 -0
- package/dist/compat/array/dropRightWhile.d.ts +60 -0
- package/dist/compat/array/dropRightWhile.mjs +27 -0
- package/dist/compat/array/every.mjs +4 -5
- package/dist/compat/array/filter.mjs +4 -5
- package/dist/compat/array/find.mjs +4 -5
- package/dist/compat/array/includes.mjs +2 -1
- package/dist/compat/array/slice.d.mts +18 -0
- package/dist/compat/array/slice.d.ts +18 -0
- package/dist/compat/array/slice.mjs +38 -0
- package/dist/compat/array/take.d.mts +25 -0
- package/dist/compat/array/take.d.ts +25 -0
- package/dist/compat/array/take.mjs +10 -0
- package/dist/compat/function/before.d.mts +26 -0
- package/dist/compat/function/before.d.ts +26 -0
- package/dist/compat/function/before.mjs +20 -0
- package/dist/compat/function/curryRight.d.mts +50 -0
- package/dist/compat/function/curryRight.d.ts +50 -0
- package/dist/compat/function/curryRight.mjs +64 -0
- package/dist/compat/index.d.mts +86 -75
- package/dist/compat/index.d.ts +86 -75
- package/dist/compat/index.js +779 -496
- package/dist/compat/index.mjs +86 -75
- package/dist/compat/object/defaults.d.mts +120 -0
- package/dist/compat/object/defaults.d.ts +120 -0
- package/dist/compat/object/defaults.mjs +21 -0
- package/dist/compat/object/invertBy.d.mts +27 -0
- package/dist/compat/object/invertBy.d.ts +27 -0
- package/dist/compat/object/invertBy.mjs +27 -0
- package/dist/compat/object/omit.d.mts +1 -1
- package/dist/compat/object/omit.d.ts +1 -1
- package/dist/compat/object/pick.d.mts +1 -1
- package/dist/compat/object/pick.d.ts +1 -1
- package/dist/compat/object/toDefaulted.d.mts +122 -0
- package/dist/compat/object/toDefaulted.d.ts +122 -0
- package/dist/compat/object/toDefaulted.mjs +9 -0
- package/dist/compat/predicate/isArrayBuffer.d.mts +20 -0
- package/dist/compat/predicate/isArrayBuffer.d.ts +20 -0
- package/dist/compat/predicate/isArrayBuffer.mjs +7 -0
- package/dist/compat/predicate/isDate.d.mts +16 -0
- package/dist/compat/predicate/isDate.d.ts +16 -0
- package/dist/compat/predicate/isDate.mjs +7 -0
- package/dist/compat/predicate/isEqualWith.d.mts +38 -0
- package/dist/compat/predicate/isEqualWith.d.ts +38 -0
- package/dist/compat/predicate/isEqualWith.mjs +23 -0
- package/dist/compat/predicate/isMap.d.mts +20 -0
- package/dist/compat/predicate/isMap.d.ts +20 -0
- package/dist/compat/predicate/isMap.mjs +7 -0
- package/dist/compat/predicate/isMatch.mjs +2 -1
- package/dist/compat/predicate/isSet.d.mts +20 -0
- package/dist/compat/predicate/isSet.d.ts +20 -0
- package/dist/compat/predicate/isSet.mjs +7 -0
- package/dist/compat/string/upperCase.mjs +0 -1
- package/dist/compat/util/constant.d.mts +16 -0
- package/dist/compat/util/constant.d.ts +16 -0
- package/dist/compat/util/constant.mjs +5 -0
- package/dist/compat/util/defaultTo.d.mts +17 -0
- package/dist/compat/util/defaultTo.d.ts +17 -0
- package/dist/compat/util/defaultTo.mjs +8 -0
- package/dist/compat/util/eq.d.mts +16 -0
- package/dist/compat/util/eq.d.ts +16 -0
- package/dist/compat/util/eq.mjs +5 -0
- package/dist/compat/util/times.d.mts +14 -0
- package/dist/compat/util/times.d.ts +14 -0
- package/dist/compat/util/times.mjs +15 -0
- package/dist/compat/util/toLength.d.mts +18 -0
- package/dist/compat/util/toLength.d.ts +18 -0
- package/dist/compat/util/toLength.mjs +12 -0
- package/dist/function/before.d.mts +2 -2
- package/dist/function/before.d.ts +2 -2
- package/dist/function/before.mjs +2 -2
- package/dist/function/index.d.mts +10 -10
- package/dist/function/index.d.ts +10 -10
- package/dist/function/index.js +65 -32
- package/dist/function/index.mjs +10 -10
- package/dist/function/once.d.mts +16 -1
- package/dist/function/once.d.ts +16 -1
- package/dist/function/once.mjs +5 -7
- package/dist/index.d.mts +43 -41
- package/dist/index.d.ts +43 -41
- package/dist/index.js +59 -57
- package/dist/index.mjs +43 -41
- package/dist/math/index.d.mts +2 -1
- package/dist/math/index.d.ts +2 -1
- package/dist/math/index.js +9 -8
- package/dist/math/index.mjs +2 -1
- package/dist/math/rangeRight.d.mts +38 -0
- package/dist/math/rangeRight.d.ts +38 -0
- package/dist/math/rangeRight.mjs +20 -0
- package/dist/object/index.d.mts +7 -7
- package/dist/object/index.d.ts +7 -7
- package/dist/object/index.js +32 -32
- package/dist/object/index.mjs +7 -7
- package/dist/object/omitBy.d.mts +1 -1
- package/dist/object/omitBy.d.ts +1 -1
- package/dist/object/omitBy.mjs +4 -3
- package/dist/object/pickBy.mjs +4 -3
- package/dist/predicate/index.d.mts +11 -10
- package/dist/predicate/index.d.ts +11 -10
- package/dist/predicate/index.js +8 -7
- package/dist/predicate/index.mjs +11 -10
- package/dist/predicate/isBlob.d.mts +19 -0
- package/dist/predicate/isBlob.d.ts +19 -0
- package/dist/predicate/isBlob.mjs +8 -0
- package/dist/predicate/isEqualWith.mjs +2 -1
- package/dist/promise/index.d.mts +1 -1
- package/dist/promise/index.d.ts +1 -1
- package/dist/promise/index.mjs +1 -1
- package/dist/string/index.d.mts +12 -12
- package/dist/string/index.d.ts +12 -12
- package/dist/string/index.js +20 -20
- package/dist/string/index.mjs +12 -12
- package/package.json +10 -6
- package/dist/_chunk/{pad-BWiShN.js → upperFirst-BUECmK.js} +84 -84
package/dist/compat/index.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
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-wpjySR.js');
|
|
6
6
|
const promise_index = require('../_chunk/index-BGZDR9.js');
|
|
7
|
-
const
|
|
7
|
+
const unary = require('../_chunk/unary-BZ5Ixo.js');
|
|
8
8
|
const noop = require('../_chunk/noop-2IwLUk.js');
|
|
9
|
-
const
|
|
9
|
+
const sumBy = require('../_chunk/sumBy-BkErWJ.js');
|
|
10
10
|
const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
11
|
-
const
|
|
11
|
+
const toMerged = require('../_chunk/toMerged-DDLv0D.js');
|
|
12
12
|
const isPlainObject$1 = require('../_chunk/isPlainObject-DgrsU7.js');
|
|
13
|
-
const isWeakSet$1 = require('../_chunk/isWeakSet-
|
|
14
|
-
const
|
|
13
|
+
const isWeakSet$1 = require('../_chunk/isWeakSet-Bd6nry.js');
|
|
14
|
+
const upperFirst = require('../_chunk/upperFirst-BUECmK.js');
|
|
15
15
|
|
|
16
16
|
function castArray(value) {
|
|
17
17
|
if (arguments.length === 0) {
|
|
@@ -32,9 +32,26 @@ function concat(...values) {
|
|
|
32
32
|
return zipWith.flatten(values);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
function isArrayLike(value) {
|
|
36
|
+
return value != null && typeof value !== 'function' && isWeakSet$1.isLength(value.length);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isArrayLikeObject(value) {
|
|
40
|
+
return toMerged.isObjectLike(value) && isArrayLike(value);
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
function difference(arr, ...values) {
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
if (!isArrayLikeObject(arr)) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const arr1 = Array.from(arr);
|
|
48
|
+
const arr2 = [];
|
|
49
|
+
for (let i = 0; i < values.length; i++) {
|
|
50
|
+
const value = values[i];
|
|
51
|
+
if (isArrayLikeObject(value)) {
|
|
52
|
+
arr2.push(...Array.from(value));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
38
55
|
return zipWith.difference(arr1, arr2);
|
|
39
56
|
}
|
|
40
57
|
|
|
@@ -221,7 +238,7 @@ function isMatch(target, source) {
|
|
|
221
238
|
}
|
|
222
239
|
default: {
|
|
223
240
|
if (!isObject(target)) {
|
|
224
|
-
return
|
|
241
|
+
return isWeakSet$1.eq(target, source);
|
|
225
242
|
}
|
|
226
243
|
return !source;
|
|
227
244
|
}
|
|
@@ -272,7 +289,7 @@ function isSetMatch(target, source) {
|
|
|
272
289
|
}
|
|
273
290
|
|
|
274
291
|
function matches(source) {
|
|
275
|
-
source =
|
|
292
|
+
source = toMerged.cloneDeep(source);
|
|
276
293
|
return (target) => {
|
|
277
294
|
return isMatch(target, source);
|
|
278
295
|
};
|
|
@@ -280,25 +297,25 @@ function matches(source) {
|
|
|
280
297
|
|
|
281
298
|
function cloneDeep(obj) {
|
|
282
299
|
if (typeof obj !== 'object') {
|
|
283
|
-
return
|
|
300
|
+
return toMerged.cloneDeep(obj);
|
|
284
301
|
}
|
|
285
302
|
switch (Object.prototype.toString.call(obj)) {
|
|
286
303
|
case isWeakSet$1.numberTag:
|
|
287
304
|
case isWeakSet$1.stringTag:
|
|
288
305
|
case isWeakSet$1.booleanTag: {
|
|
289
306
|
const result = new obj.constructor(obj?.valueOf());
|
|
290
|
-
|
|
307
|
+
toMerged.copyProperties(result, obj);
|
|
291
308
|
return result;
|
|
292
309
|
}
|
|
293
310
|
case isWeakSet$1.argumentsTag: {
|
|
294
311
|
const result = {};
|
|
295
|
-
|
|
312
|
+
toMerged.copyProperties(result, obj);
|
|
296
313
|
result.length = obj.length;
|
|
297
314
|
result[Symbol.iterator] = obj[Symbol.iterator];
|
|
298
315
|
return result;
|
|
299
316
|
}
|
|
300
317
|
default: {
|
|
301
|
-
return
|
|
318
|
+
return toMerged.cloneDeep(obj);
|
|
302
319
|
}
|
|
303
320
|
}
|
|
304
321
|
}
|
|
@@ -376,6 +393,27 @@ function matchesProperty(property, source) {
|
|
|
376
393
|
};
|
|
377
394
|
}
|
|
378
395
|
|
|
396
|
+
function dropRightWhile(arr, predicate) {
|
|
397
|
+
switch (typeof predicate) {
|
|
398
|
+
case 'function': {
|
|
399
|
+
return zipWith.dropRightWhile(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
|
|
400
|
+
}
|
|
401
|
+
case 'object': {
|
|
402
|
+
if (Array.isArray(predicate) && predicate.length === 2) {
|
|
403
|
+
const key = predicate[0];
|
|
404
|
+
const value = predicate[1];
|
|
405
|
+
return zipWith.dropRightWhile(arr, matchesProperty(key, value));
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
return zipWith.dropRightWhile(arr, matches(predicate));
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
case 'string': {
|
|
412
|
+
return zipWith.dropRightWhile(arr, property(predicate));
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
379
417
|
function dropWhile(arr, predicate) {
|
|
380
418
|
switch (typeof predicate) {
|
|
381
419
|
case 'function': {
|
|
@@ -415,11 +453,10 @@ function every(source, doesMatch) {
|
|
|
415
453
|
switch (typeof doesMatch) {
|
|
416
454
|
case 'function': {
|
|
417
455
|
if (!Array.isArray(source)) {
|
|
418
|
-
const
|
|
419
|
-
for (let i = 0; i <
|
|
420
|
-
const
|
|
421
|
-
const
|
|
422
|
-
const value = entry[1];
|
|
456
|
+
const keys = Object.keys(source);
|
|
457
|
+
for (let i = 0; i < keys.length; i++) {
|
|
458
|
+
const key = keys[i];
|
|
459
|
+
const value = source[key];
|
|
423
460
|
if (!doesMatch(value, key, source)) {
|
|
424
461
|
return false;
|
|
425
462
|
}
|
|
@@ -456,6 +493,42 @@ function fill(array, value, start = 0, end = array.length) {
|
|
|
456
493
|
return zipWith.fill(array, value, start, end);
|
|
457
494
|
}
|
|
458
495
|
|
|
496
|
+
function isArray(value) {
|
|
497
|
+
return Array.isArray(value);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function filter(source, predicate) {
|
|
501
|
+
if (!predicate) {
|
|
502
|
+
predicate = identity;
|
|
503
|
+
}
|
|
504
|
+
const collection = isArray(source) ? source : Object.values(source);
|
|
505
|
+
switch (typeof predicate) {
|
|
506
|
+
case 'function': {
|
|
507
|
+
if (!Array.isArray(source)) {
|
|
508
|
+
const result = [];
|
|
509
|
+
const keys = Object.keys(source);
|
|
510
|
+
for (let i = 0; i < keys.length; i++) {
|
|
511
|
+
const key = keys[i];
|
|
512
|
+
const value = source[key];
|
|
513
|
+
if (predicate(value, key, source)) {
|
|
514
|
+
result.push(value);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return result;
|
|
518
|
+
}
|
|
519
|
+
return collection.filter(predicate);
|
|
520
|
+
}
|
|
521
|
+
case 'object': {
|
|
522
|
+
return isArray(predicate)
|
|
523
|
+
? collection.filter(matchesProperty(predicate[0], predicate[1]))
|
|
524
|
+
: collection.filter(matches(predicate));
|
|
525
|
+
}
|
|
526
|
+
case 'string': {
|
|
527
|
+
return collection.filter(property(predicate));
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
459
532
|
function find(source, doesMatch) {
|
|
460
533
|
let values = source;
|
|
461
534
|
if (!Array.isArray(source)) {
|
|
@@ -464,11 +537,10 @@ function find(source, doesMatch) {
|
|
|
464
537
|
switch (typeof doesMatch) {
|
|
465
538
|
case 'function': {
|
|
466
539
|
if (!Array.isArray(source)) {
|
|
467
|
-
const
|
|
468
|
-
for (let i = 0; i <
|
|
469
|
-
const
|
|
470
|
-
const
|
|
471
|
-
const value = entry[1];
|
|
540
|
+
const keys = Object.keys(source);
|
|
541
|
+
for (let i = 0; i < keys.length; i++) {
|
|
542
|
+
const key = keys[i];
|
|
543
|
+
const value = source[key];
|
|
472
544
|
if (doesMatch(value, key, source)) {
|
|
473
545
|
return value;
|
|
474
546
|
}
|
|
@@ -640,7 +712,7 @@ function includes(source, target, fromIndex, guard) {
|
|
|
640
712
|
}
|
|
641
713
|
for (let i = fromIndex; i < keys.length; i++) {
|
|
642
714
|
const value = Reflect.get(source, keys[i]);
|
|
643
|
-
if (
|
|
715
|
+
if (isWeakSet$1.eq(value, target)) {
|
|
644
716
|
return true;
|
|
645
717
|
}
|
|
646
718
|
}
|
|
@@ -787,10 +859,6 @@ function orderBy(collection, criteria, orders) {
|
|
|
787
859
|
.map(item => item.original);
|
|
788
860
|
}
|
|
789
861
|
|
|
790
|
-
function sortBy(collection, criteria) {
|
|
791
|
-
return orderBy(collection, criteria, ['asc']);
|
|
792
|
-
}
|
|
793
|
-
|
|
794
862
|
function size(target) {
|
|
795
863
|
if (isWeakSet$1.isNil(target)) {
|
|
796
864
|
return 0;
|
|
@@ -801,6 +869,51 @@ function size(target) {
|
|
|
801
869
|
return Object.keys(target).length;
|
|
802
870
|
}
|
|
803
871
|
|
|
872
|
+
function isIterateeCall(value, index, object) {
|
|
873
|
+
if (!isObject(object)) {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
if ((typeof index === 'number' && isArrayLike(object) && isIndex(index) && index < object.length) ||
|
|
877
|
+
(typeof index === 'string' && index in object)) {
|
|
878
|
+
return isWeakSet$1.eq(object[index], value);
|
|
879
|
+
}
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
function slice(array, start, end) {
|
|
884
|
+
if (array == null) {
|
|
885
|
+
return [];
|
|
886
|
+
}
|
|
887
|
+
const length = array.length;
|
|
888
|
+
if (end === undefined) {
|
|
889
|
+
end = length;
|
|
890
|
+
}
|
|
891
|
+
else if (typeof end !== 'number' && isIterateeCall(array, start, end)) {
|
|
892
|
+
start = 0;
|
|
893
|
+
end = length;
|
|
894
|
+
}
|
|
895
|
+
start = toInteger(start);
|
|
896
|
+
end = toInteger(end);
|
|
897
|
+
if (start < 0) {
|
|
898
|
+
start = Math.max(length + start, 0);
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
start = Math.min(start, length);
|
|
902
|
+
}
|
|
903
|
+
if (end < 0) {
|
|
904
|
+
end = Math.max(length + end, 0);
|
|
905
|
+
}
|
|
906
|
+
else {
|
|
907
|
+
end = Math.min(end, length);
|
|
908
|
+
}
|
|
909
|
+
const resultLength = Math.max(end - start, 0);
|
|
910
|
+
const result = new Array(resultLength);
|
|
911
|
+
for (let i = 0; i < resultLength; ++i) {
|
|
912
|
+
result[i] = array[start + i];
|
|
913
|
+
}
|
|
914
|
+
return result;
|
|
915
|
+
}
|
|
916
|
+
|
|
804
917
|
function some(arr, predicate, guard) {
|
|
805
918
|
if (guard != null) {
|
|
806
919
|
predicate = undefined;
|
|
@@ -831,6 +944,17 @@ function some(arr, predicate, guard) {
|
|
|
831
944
|
}
|
|
832
945
|
}
|
|
833
946
|
|
|
947
|
+
function sortBy(collection, criteria) {
|
|
948
|
+
return orderBy(collection, criteria, ['asc']);
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
function take(arr, count) {
|
|
952
|
+
if (count < 1) {
|
|
953
|
+
return [];
|
|
954
|
+
}
|
|
955
|
+
return zipWith.take(arr, count);
|
|
956
|
+
}
|
|
957
|
+
|
|
834
958
|
function set(obj, path, value) {
|
|
835
959
|
const resolvedPath = Array.isArray(path) ? path : typeof path === 'string' ? toPath(path) : [path];
|
|
836
960
|
let current = obj;
|
|
@@ -859,43 +983,6 @@ function zipObjectDeep(keys, values) {
|
|
|
859
983
|
return result;
|
|
860
984
|
}
|
|
861
985
|
|
|
862
|
-
function isArray(value) {
|
|
863
|
-
return Array.isArray(value);
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
function filter(source, predicate) {
|
|
867
|
-
if (!predicate) {
|
|
868
|
-
predicate = identity;
|
|
869
|
-
}
|
|
870
|
-
const collection = isArray(source) ? source : Object.values(source);
|
|
871
|
-
switch (typeof predicate) {
|
|
872
|
-
case 'function': {
|
|
873
|
-
if (!Array.isArray(source)) {
|
|
874
|
-
const result = [];
|
|
875
|
-
const entries = Object.entries(source);
|
|
876
|
-
for (let i = 0; i < entries.length; i++) {
|
|
877
|
-
const entry = entries[i];
|
|
878
|
-
const key = entry[0];
|
|
879
|
-
const value = entry[1];
|
|
880
|
-
if (predicate(value, key, source)) {
|
|
881
|
-
result.push(value);
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
return result;
|
|
885
|
-
}
|
|
886
|
-
return collection.filter(predicate);
|
|
887
|
-
}
|
|
888
|
-
case 'object': {
|
|
889
|
-
return isArray(predicate)
|
|
890
|
-
? collection.filter(matchesProperty(predicate[0], predicate[1]))
|
|
891
|
-
: collection.filter(matches(predicate));
|
|
892
|
-
}
|
|
893
|
-
case 'string': {
|
|
894
|
-
return collection.filter(property(predicate));
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
|
|
899
986
|
function ary(func, n = func.length, guard) {
|
|
900
987
|
if (guard) {
|
|
901
988
|
n = func.length;
|
|
@@ -903,7 +990,33 @@ function ary(func, n = func.length, guard) {
|
|
|
903
990
|
if (Number.isNaN(n) || n < 0) {
|
|
904
991
|
n = 0;
|
|
905
992
|
}
|
|
906
|
-
return
|
|
993
|
+
return unary.ary(func, n);
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
function attempt(func, ...args) {
|
|
997
|
+
try {
|
|
998
|
+
return func(...args);
|
|
999
|
+
}
|
|
1000
|
+
catch (e) {
|
|
1001
|
+
return e instanceof Error ? e : new Error(e);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
function before(n, func) {
|
|
1006
|
+
if (typeof func !== 'function') {
|
|
1007
|
+
throw new TypeError('Expected a function');
|
|
1008
|
+
}
|
|
1009
|
+
let result;
|
|
1010
|
+
n = toInteger(n);
|
|
1011
|
+
return function (...args) {
|
|
1012
|
+
if (--n > 0) {
|
|
1013
|
+
result = func.apply(this, args);
|
|
1014
|
+
}
|
|
1015
|
+
if (n <= 1 && func) {
|
|
1016
|
+
func = undefined;
|
|
1017
|
+
}
|
|
1018
|
+
return result;
|
|
1019
|
+
};
|
|
907
1020
|
}
|
|
908
1021
|
|
|
909
1022
|
function bind(func, thisObj, ...partialArgs) {
|
|
@@ -958,56 +1071,6 @@ function bindKey(object, key, ...partialArgs) {
|
|
|
958
1071
|
const bindKeyPlaceholder = Symbol('bindKey.placeholder');
|
|
959
1072
|
bindKey.placeholder = bindKeyPlaceholder;
|
|
960
1073
|
|
|
961
|
-
function defer(func, ...args) {
|
|
962
|
-
if (typeof func !== 'function') {
|
|
963
|
-
throw new TypeError('Expected a function');
|
|
964
|
-
}
|
|
965
|
-
return setTimeout(func, 1, ...args);
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
function rest(func, start = func.length - 1) {
|
|
969
|
-
start = Number.parseInt(start, 10);
|
|
970
|
-
if (Number.isNaN(start) || start < 0) {
|
|
971
|
-
start = func.length - 1;
|
|
972
|
-
}
|
|
973
|
-
return flowRight$1.rest(func, start);
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
function spread(func, argsIndex = 0) {
|
|
977
|
-
argsIndex = Number.parseInt(argsIndex, 10);
|
|
978
|
-
if (Number.isNaN(argsIndex) || argsIndex < 0) {
|
|
979
|
-
argsIndex = 0;
|
|
980
|
-
}
|
|
981
|
-
return function (...args) {
|
|
982
|
-
const array = args[argsIndex];
|
|
983
|
-
const params = args.slice(0, argsIndex);
|
|
984
|
-
if (array) {
|
|
985
|
-
params.push(...array);
|
|
986
|
-
}
|
|
987
|
-
return func.apply(this, params);
|
|
988
|
-
};
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
function attempt(func, ...args) {
|
|
992
|
-
try {
|
|
993
|
-
return func(...args);
|
|
994
|
-
}
|
|
995
|
-
catch (e) {
|
|
996
|
-
return e instanceof Error ? e : new Error(e);
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
function rearg(func, ...indices) {
|
|
1001
|
-
const flattenIndices = flatten(indices);
|
|
1002
|
-
return function (...args) {
|
|
1003
|
-
const reorderedArgs = flattenIndices.map(i => args[i]).slice(0, args.length);
|
|
1004
|
-
for (let i = reorderedArgs.length; i < args.length; i++) {
|
|
1005
|
-
reorderedArgs.push(args[i]);
|
|
1006
|
-
}
|
|
1007
|
-
return func.apply(this, reorderedArgs);
|
|
1008
|
-
};
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
1074
|
function curry(func, arity = func.length, guard) {
|
|
1012
1075
|
arity = guard ? func.length : arity;
|
|
1013
1076
|
arity = Number.parseInt(arity, 10);
|
|
@@ -1032,7 +1095,7 @@ function makeCurry(func, arity, partialArgs) {
|
|
|
1032
1095
|
function wrapper(...providedArgs) {
|
|
1033
1096
|
const holders = providedArgs.filter(item => item === curry.placeholder);
|
|
1034
1097
|
const length = providedArgs.length - holders.length;
|
|
1035
|
-
providedArgs = composeArgs(providedArgs, partialArgs);
|
|
1098
|
+
providedArgs = composeArgs$1(providedArgs, partialArgs);
|
|
1036
1099
|
if (length < arity) {
|
|
1037
1100
|
return makeCurry(func, arity - length, providedArgs);
|
|
1038
1101
|
}
|
|
@@ -1044,7 +1107,7 @@ function makeCurry(func, arity, partialArgs) {
|
|
|
1044
1107
|
wrapper.placeholder = curryPlaceholder;
|
|
1045
1108
|
return wrapper;
|
|
1046
1109
|
}
|
|
1047
|
-
function composeArgs(providedArgs, partialArgs) {
|
|
1110
|
+
function composeArgs$1(providedArgs, partialArgs) {
|
|
1048
1111
|
const args = [];
|
|
1049
1112
|
let startIndex = 0;
|
|
1050
1113
|
for (let i = 0; i < partialArgs.length; i++) {
|
|
@@ -1064,6 +1127,69 @@ function composeArgs(providedArgs, partialArgs) {
|
|
|
1064
1127
|
const curryPlaceholder = Symbol('curry.placeholder');
|
|
1065
1128
|
curry.placeholder = curryPlaceholder;
|
|
1066
1129
|
|
|
1130
|
+
function curryRight(func, arity = func.length, guard) {
|
|
1131
|
+
arity = guard ? func.length : arity;
|
|
1132
|
+
arity = Number.parseInt(arity, 10);
|
|
1133
|
+
if (Number.isNaN(arity) || arity < 1) {
|
|
1134
|
+
arity = 0;
|
|
1135
|
+
}
|
|
1136
|
+
const wrapper = function (...partialArgs) {
|
|
1137
|
+
const holders = partialArgs.filter(item => item === curryRight.placeholder);
|
|
1138
|
+
const length = partialArgs.length - holders.length;
|
|
1139
|
+
if (length < arity) {
|
|
1140
|
+
return makeCurryRight(func, arity - length, partialArgs);
|
|
1141
|
+
}
|
|
1142
|
+
if (this instanceof wrapper) {
|
|
1143
|
+
return new func(...partialArgs);
|
|
1144
|
+
}
|
|
1145
|
+
return func.apply(this, partialArgs);
|
|
1146
|
+
};
|
|
1147
|
+
wrapper.placeholder = curryRightPlaceholder;
|
|
1148
|
+
return wrapper;
|
|
1149
|
+
}
|
|
1150
|
+
function makeCurryRight(func, arity, partialArgs) {
|
|
1151
|
+
function wrapper(...providedArgs) {
|
|
1152
|
+
const holders = providedArgs.filter(item => item === curryRight.placeholder);
|
|
1153
|
+
const length = providedArgs.length - holders.length;
|
|
1154
|
+
providedArgs = composeArgs(providedArgs, partialArgs);
|
|
1155
|
+
if (length < arity) {
|
|
1156
|
+
return makeCurryRight(func, arity - length, providedArgs);
|
|
1157
|
+
}
|
|
1158
|
+
if (this instanceof wrapper) {
|
|
1159
|
+
return new func(...providedArgs);
|
|
1160
|
+
}
|
|
1161
|
+
return func.apply(this, providedArgs);
|
|
1162
|
+
}
|
|
1163
|
+
wrapper.placeholder = curryRightPlaceholder;
|
|
1164
|
+
return wrapper;
|
|
1165
|
+
}
|
|
1166
|
+
function composeArgs(providedArgs, partialArgs) {
|
|
1167
|
+
const placeholderLength = partialArgs.filter(arg => arg === curryRight.placeholder).length;
|
|
1168
|
+
const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
|
|
1169
|
+
const args = [];
|
|
1170
|
+
let providedIndex = 0;
|
|
1171
|
+
for (let i = 0; i < rangeLength; i++) {
|
|
1172
|
+
args.push(providedArgs[providedIndex++]);
|
|
1173
|
+
}
|
|
1174
|
+
for (let i = 0; i < partialArgs.length; i++) {
|
|
1175
|
+
const arg = partialArgs[i];
|
|
1176
|
+
if (arg === curryRight.placeholder) {
|
|
1177
|
+
if (providedIndex < providedArgs.length) {
|
|
1178
|
+
args.push(providedArgs[providedIndex++]);
|
|
1179
|
+
}
|
|
1180
|
+
else {
|
|
1181
|
+
args.push(arg);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
else {
|
|
1185
|
+
args.push(arg);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
return args;
|
|
1189
|
+
}
|
|
1190
|
+
const curryRightPlaceholder = Symbol('curryRight.placeholder');
|
|
1191
|
+
curryRight.placeholder = curryRightPlaceholder;
|
|
1192
|
+
|
|
1067
1193
|
function debounce(func, debounceMs = 0, options = {}) {
|
|
1068
1194
|
if (typeof options !== 'object') {
|
|
1069
1195
|
options = {};
|
|
@@ -1078,7 +1204,7 @@ function debounce(func, debounceMs = 0, options = {}) {
|
|
|
1078
1204
|
}
|
|
1079
1205
|
let result = undefined;
|
|
1080
1206
|
let pendingAt = null;
|
|
1081
|
-
const _debounced =
|
|
1207
|
+
const _debounced = unary.debounce(function (...args) {
|
|
1082
1208
|
result = func.apply(this, args);
|
|
1083
1209
|
pendingAt = null;
|
|
1084
1210
|
}, debounceMs, { signal, edges });
|
|
@@ -1109,12 +1235,11 @@ function debounce(func, debounceMs = 0, options = {}) {
|
|
|
1109
1235
|
return debounced;
|
|
1110
1236
|
}
|
|
1111
1237
|
|
|
1112
|
-
function
|
|
1113
|
-
if (typeof
|
|
1114
|
-
|
|
1238
|
+
function defer(func, ...args) {
|
|
1239
|
+
if (typeof func !== 'function') {
|
|
1240
|
+
throw new TypeError('Expected a function');
|
|
1115
1241
|
}
|
|
1116
|
-
|
|
1117
|
-
return debounce(func, throttleMs, { leading, trailing, signal, maxWait: throttleMs });
|
|
1242
|
+
return setTimeout(func, 1, ...args);
|
|
1118
1243
|
}
|
|
1119
1244
|
|
|
1120
1245
|
function flip(func) {
|
|
@@ -1128,7 +1253,7 @@ function flow(...funcs) {
|
|
|
1128
1253
|
if (flattenFuncs.some(func => typeof func !== 'function')) {
|
|
1129
1254
|
throw new TypeError('Expected a function');
|
|
1130
1255
|
}
|
|
1131
|
-
return
|
|
1256
|
+
return unary.flow(...flattenFuncs);
|
|
1132
1257
|
}
|
|
1133
1258
|
|
|
1134
1259
|
function flowRight(...funcs) {
|
|
@@ -1136,133 +1261,261 @@ function flowRight(...funcs) {
|
|
|
1136
1261
|
if (flattenFuncs.some(func => typeof func !== 'function')) {
|
|
1137
1262
|
throw new TypeError('Expected a function');
|
|
1138
1263
|
}
|
|
1139
|
-
return
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
function isNil(x) {
|
|
1143
|
-
return x == null;
|
|
1264
|
+
return unary.flowRight(...flattenFuncs);
|
|
1144
1265
|
}
|
|
1145
1266
|
|
|
1146
|
-
function
|
|
1147
|
-
|
|
1148
|
-
|
|
1267
|
+
function rearg(func, ...indices) {
|
|
1268
|
+
const flattenIndices = flatten(indices);
|
|
1269
|
+
return function (...args) {
|
|
1270
|
+
const reorderedArgs = flattenIndices.map(i => args[i]).slice(0, args.length);
|
|
1271
|
+
for (let i = reorderedArgs.length; i < args.length; i++) {
|
|
1272
|
+
reorderedArgs.push(args[i]);
|
|
1273
|
+
}
|
|
1274
|
+
return func.apply(this, reorderedArgs);
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
function rest(func, start = func.length - 1) {
|
|
1279
|
+
start = Number.parseInt(start, 10);
|
|
1280
|
+
if (Number.isNaN(start) || start < 0) {
|
|
1281
|
+
start = func.length - 1;
|
|
1149
1282
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
keys = [keys];
|
|
1164
|
-
break;
|
|
1165
|
-
}
|
|
1283
|
+
return unary.rest(func, start);
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
function spread(func, argsIndex = 0) {
|
|
1287
|
+
argsIndex = Number.parseInt(argsIndex, 10);
|
|
1288
|
+
if (Number.isNaN(argsIndex) || argsIndex < 0) {
|
|
1289
|
+
argsIndex = 0;
|
|
1290
|
+
}
|
|
1291
|
+
return function (...args) {
|
|
1292
|
+
const array = args[argsIndex];
|
|
1293
|
+
const params = args.slice(0, argsIndex);
|
|
1294
|
+
if (array) {
|
|
1295
|
+
params.push(...array);
|
|
1166
1296
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1297
|
+
return func.apply(this, params);
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
function throttle(func, throttleMs = 0, options = {}) {
|
|
1302
|
+
if (typeof options !== 'object') {
|
|
1303
|
+
options = {};
|
|
1304
|
+
}
|
|
1305
|
+
const { leading = true, trailing = true, signal } = options;
|
|
1306
|
+
return debounce(func, throttleMs, { leading, trailing, signal, maxWait: throttleMs });
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
function decimalAdjust(type, number, precision = 0) {
|
|
1310
|
+
number = Number(number);
|
|
1311
|
+
if (Object.is(number, -0)) {
|
|
1312
|
+
number = '-0';
|
|
1313
|
+
}
|
|
1314
|
+
precision = Math.min(Number.parseInt(precision, 10), 292);
|
|
1315
|
+
if (precision) {
|
|
1316
|
+
const [magnitude, exponent = 0] = number.toString().split('e');
|
|
1317
|
+
let adjustedValue = Math[type](Number(`${magnitude}e${Number(exponent) + precision}`));
|
|
1318
|
+
if (Object.is(adjustedValue, -0)) {
|
|
1319
|
+
adjustedValue = '-0';
|
|
1175
1320
|
}
|
|
1321
|
+
const [newMagnitude, newExponent = 0] = adjustedValue.toString().split('e');
|
|
1322
|
+
return Number(`${newMagnitude}e${Number(newExponent) - precision}`);
|
|
1176
1323
|
}
|
|
1177
|
-
return
|
|
1324
|
+
return Math[type](Number(number));
|
|
1178
1325
|
}
|
|
1179
1326
|
|
|
1180
|
-
function
|
|
1181
|
-
|
|
1182
|
-
|
|
1327
|
+
function ceil(number, precision = 0) {
|
|
1328
|
+
return decimalAdjust('ceil', number, precision);
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
function clamp(value, bound1, bound2) {
|
|
1332
|
+
if (Number.isNaN(bound1)) {
|
|
1333
|
+
bound1 = 0;
|
|
1183
1334
|
}
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1335
|
+
if (Number.isNaN(bound2)) {
|
|
1336
|
+
bound2 = 0;
|
|
1337
|
+
}
|
|
1338
|
+
return sumBy.clamp(value, bound1, bound2);
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
function floor(number, precision = 0) {
|
|
1342
|
+
return decimalAdjust('floor', number, precision);
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
function inRange(value, minimum, maximum) {
|
|
1346
|
+
if (!minimum) {
|
|
1347
|
+
minimum = 0;
|
|
1348
|
+
}
|
|
1349
|
+
if (maximum != null && !maximum) {
|
|
1350
|
+
maximum = 0;
|
|
1351
|
+
}
|
|
1352
|
+
if (minimum != null && typeof minimum !== 'number') {
|
|
1353
|
+
minimum = Number(minimum);
|
|
1354
|
+
}
|
|
1355
|
+
if (maximum == null && minimum === 0) {
|
|
1356
|
+
return false;
|
|
1357
|
+
}
|
|
1358
|
+
if (maximum != null && typeof maximum !== 'number') {
|
|
1359
|
+
maximum = Number(maximum);
|
|
1360
|
+
}
|
|
1361
|
+
if (maximum != null && minimum > maximum) {
|
|
1362
|
+
[minimum, maximum] = [maximum, minimum];
|
|
1363
|
+
}
|
|
1364
|
+
if (minimum === maximum) {
|
|
1365
|
+
return false;
|
|
1366
|
+
}
|
|
1367
|
+
return sumBy.inRange(value, minimum, maximum);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
function max(items = []) {
|
|
1371
|
+
let maxElement = items[0];
|
|
1372
|
+
let max = undefined;
|
|
1373
|
+
for (let i = 0; i < items.length; i++) {
|
|
1374
|
+
const element = items[i];
|
|
1375
|
+
if (max == null || element > max) {
|
|
1376
|
+
max = element;
|
|
1377
|
+
maxElement = element;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
return maxElement;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
function min(items = []) {
|
|
1384
|
+
let minElement = items[0];
|
|
1385
|
+
let min = undefined;
|
|
1386
|
+
for (let i = 0; i < items.length; i++) {
|
|
1387
|
+
const element = items[i];
|
|
1388
|
+
if (min == null || element < min) {
|
|
1389
|
+
min = element;
|
|
1390
|
+
minElement = element;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
return minElement;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
function parseInt(string, radix = 0, guard) {
|
|
1397
|
+
if (guard) {
|
|
1398
|
+
radix = 0;
|
|
1399
|
+
}
|
|
1400
|
+
return Number.parseInt(string, radix);
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
function random(...args) {
|
|
1404
|
+
let minimum = 0;
|
|
1405
|
+
let maximum = 1;
|
|
1406
|
+
let floating = false;
|
|
1407
|
+
switch (args.length) {
|
|
1408
|
+
case 1: {
|
|
1409
|
+
if (typeof args[0] === 'boolean') {
|
|
1410
|
+
floating = args[0];
|
|
1201
1411
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1412
|
+
else {
|
|
1413
|
+
maximum = args[0];
|
|
1204
1414
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1415
|
+
break;
|
|
1416
|
+
}
|
|
1417
|
+
case 2: {
|
|
1418
|
+
if (typeof args[1] === 'boolean') {
|
|
1419
|
+
maximum = args[0];
|
|
1420
|
+
floating = args[1];
|
|
1208
1421
|
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1422
|
+
else {
|
|
1423
|
+
minimum = args[0];
|
|
1424
|
+
maximum = args[1];
|
|
1211
1425
|
}
|
|
1212
1426
|
}
|
|
1213
|
-
case
|
|
1214
|
-
if (
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
delete obj[path];
|
|
1219
|
-
return true;
|
|
1427
|
+
case 3: {
|
|
1428
|
+
if (typeof args[2] === 'object' && args[2] != null && args[2][args[1]] === args[0]) {
|
|
1429
|
+
minimum = 0;
|
|
1430
|
+
maximum = args[0];
|
|
1431
|
+
floating = false;
|
|
1220
1432
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1433
|
+
else {
|
|
1434
|
+
minimum = args[0];
|
|
1435
|
+
maximum = args[1];
|
|
1436
|
+
floating = args[2];
|
|
1223
1437
|
}
|
|
1224
1438
|
}
|
|
1225
1439
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
const parent = get(obj, path.slice(0, -1), obj);
|
|
1229
|
-
const lastKey = path[path.length - 1];
|
|
1230
|
-
if (parent?.[lastKey] === undefined) {
|
|
1231
|
-
return true;
|
|
1440
|
+
if (typeof minimum !== 'number') {
|
|
1441
|
+
minimum = Number(minimum);
|
|
1232
1442
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
return true;
|
|
1443
|
+
if (typeof maximum !== 'number') {
|
|
1444
|
+
minimum = Number(maximum);
|
|
1236
1445
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1446
|
+
if (!minimum) {
|
|
1447
|
+
minimum = 0;
|
|
1448
|
+
}
|
|
1449
|
+
if (!maximum) {
|
|
1450
|
+
maximum = 0;
|
|
1451
|
+
}
|
|
1452
|
+
if (minimum > maximum) {
|
|
1453
|
+
[minimum, maximum] = [maximum, minimum];
|
|
1454
|
+
}
|
|
1455
|
+
minimum = clamp(minimum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
1456
|
+
maximum = clamp(maximum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
1457
|
+
if (minimum === maximum) {
|
|
1458
|
+
return minimum;
|
|
1459
|
+
}
|
|
1460
|
+
if (floating) {
|
|
1461
|
+
return randomInt.random(minimum, maximum + 1);
|
|
1462
|
+
}
|
|
1463
|
+
else {
|
|
1464
|
+
return randomInt.randomInt(minimum, maximum + 1);
|
|
1239
1465
|
}
|
|
1240
1466
|
}
|
|
1241
1467
|
|
|
1242
|
-
function
|
|
1243
|
-
|
|
1468
|
+
function round(number, precision = 0) {
|
|
1469
|
+
return decimalAdjust('round', number, precision);
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
function defaults(object, ...sources) {
|
|
1473
|
+
object = Object(object);
|
|
1474
|
+
const objectProto = Object.prototype;
|
|
1475
|
+
for (let i = 0; i < sources.length; i++) {
|
|
1476
|
+
const source = sources[i];
|
|
1477
|
+
const keys = Object.keys(source);
|
|
1478
|
+
for (let j = 0; j < keys.length; j++) {
|
|
1479
|
+
const key = keys[j];
|
|
1480
|
+
const value = object[key];
|
|
1481
|
+
if (value === undefined ||
|
|
1482
|
+
(!Object.hasOwn(object, key) && isWeakSet$1.eq(value, objectProto[key]))) {
|
|
1483
|
+
object[key] = source[key];
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
return object;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
function fromPairs(pairs) {
|
|
1491
|
+
if (!isArrayLike(pairs) && !(pairs instanceof Map)) {
|
|
1244
1492
|
return {};
|
|
1245
1493
|
}
|
|
1246
|
-
const result =
|
|
1247
|
-
for (
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1494
|
+
const result = {};
|
|
1495
|
+
for (const [key, value] of pairs) {
|
|
1496
|
+
result[key] = value;
|
|
1497
|
+
}
|
|
1498
|
+
return result;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
function invertBy(object, iteratee) {
|
|
1502
|
+
const result = {};
|
|
1503
|
+
if (isWeakSet$1.isNil(object)) {
|
|
1504
|
+
return result;
|
|
1505
|
+
}
|
|
1506
|
+
if (iteratee == null) {
|
|
1507
|
+
iteratee = identity;
|
|
1508
|
+
}
|
|
1509
|
+
const keys = Object.keys(object);
|
|
1510
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1511
|
+
const key = keys[i];
|
|
1512
|
+
const value = object[key];
|
|
1513
|
+
const valueStr = iteratee(value);
|
|
1514
|
+
if (Array.isArray(result[valueStr])) {
|
|
1515
|
+
result[valueStr].push(key);
|
|
1516
|
+
}
|
|
1517
|
+
else {
|
|
1518
|
+
result[valueStr] = [key];
|
|
1266
1519
|
}
|
|
1267
1520
|
}
|
|
1268
1521
|
return result;
|
|
@@ -1275,10 +1528,10 @@ function mapKeys(object, getNewKey) {
|
|
|
1275
1528
|
case 'symbol':
|
|
1276
1529
|
case 'number':
|
|
1277
1530
|
case 'object': {
|
|
1278
|
-
return
|
|
1531
|
+
return toMerged.mapKeys(object, property(getNewKey));
|
|
1279
1532
|
}
|
|
1280
1533
|
case 'function': {
|
|
1281
|
-
return
|
|
1534
|
+
return toMerged.mapKeys(object, getNewKey);
|
|
1282
1535
|
}
|
|
1283
1536
|
}
|
|
1284
1537
|
}
|
|
@@ -1290,10 +1543,10 @@ function mapValues(object, getNewValue) {
|
|
|
1290
1543
|
case 'symbol':
|
|
1291
1544
|
case 'number':
|
|
1292
1545
|
case 'object': {
|
|
1293
|
-
return
|
|
1546
|
+
return toMerged.mapValues(object, property(getNewValue));
|
|
1294
1547
|
}
|
|
1295
1548
|
case 'function': {
|
|
1296
|
-
return
|
|
1549
|
+
return toMerged.mapValues(object, getNewValue);
|
|
1297
1550
|
}
|
|
1298
1551
|
}
|
|
1299
1552
|
}
|
|
@@ -1345,7 +1598,7 @@ function mergeWithDeep(target, source, merge, stack) {
|
|
|
1345
1598
|
return target;
|
|
1346
1599
|
}
|
|
1347
1600
|
if (stack.has(source)) {
|
|
1348
|
-
return
|
|
1601
|
+
return toMerged.clone(stack.get(source));
|
|
1349
1602
|
}
|
|
1350
1603
|
stack.set(source, target);
|
|
1351
1604
|
if (Array.isArray(source)) {
|
|
@@ -1389,7 +1642,7 @@ function mergeWithDeep(target, source, merge, stack) {
|
|
|
1389
1642
|
else if (Array.isArray(sourceValue)) {
|
|
1390
1643
|
target[key] = mergeWithDeep(targetValue, sourceValue, merge, stack);
|
|
1391
1644
|
}
|
|
1392
|
-
else if (
|
|
1645
|
+
else if (toMerged.isObjectLike(targetValue) && toMerged.isObjectLike(sourceValue)) {
|
|
1393
1646
|
target[key] = mergeWithDeep(targetValue, sourceValue, merge, stack);
|
|
1394
1647
|
}
|
|
1395
1648
|
else if (targetValue == null && isPlainObject(sourceValue)) {
|
|
@@ -1409,43 +1662,138 @@ function merge(object, ...sources) {
|
|
|
1409
1662
|
return mergeWith(object, ...sources, noop.noop);
|
|
1410
1663
|
}
|
|
1411
1664
|
|
|
1412
|
-
function
|
|
1413
|
-
|
|
1665
|
+
function unset(obj, path) {
|
|
1666
|
+
if (obj == null) {
|
|
1667
|
+
return true;
|
|
1668
|
+
}
|
|
1669
|
+
switch (typeof path) {
|
|
1670
|
+
case 'symbol':
|
|
1671
|
+
case 'number':
|
|
1672
|
+
case 'object': {
|
|
1673
|
+
if (Array.isArray(path)) {
|
|
1674
|
+
return unsetWithPath(obj, path);
|
|
1675
|
+
}
|
|
1676
|
+
if (typeof path === 'number') {
|
|
1677
|
+
path = toKey(path);
|
|
1678
|
+
}
|
|
1679
|
+
else if (typeof path === 'object') {
|
|
1680
|
+
if (Object.is(path?.valueOf(), -0)) {
|
|
1681
|
+
path = '-0';
|
|
1682
|
+
}
|
|
1683
|
+
else {
|
|
1684
|
+
path = String(path);
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
if (obj?.[path] === undefined) {
|
|
1688
|
+
return true;
|
|
1689
|
+
}
|
|
1690
|
+
try {
|
|
1691
|
+
delete obj[path];
|
|
1692
|
+
return true;
|
|
1693
|
+
}
|
|
1694
|
+
catch {
|
|
1695
|
+
return false;
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
case 'string': {
|
|
1699
|
+
if (obj?.[path] === undefined && isDeepKey(path)) {
|
|
1700
|
+
return unsetWithPath(obj, toPath(path));
|
|
1701
|
+
}
|
|
1702
|
+
try {
|
|
1703
|
+
delete obj[path];
|
|
1704
|
+
return true;
|
|
1705
|
+
}
|
|
1706
|
+
catch {
|
|
1707
|
+
return false;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
function unsetWithPath(obj, path) {
|
|
1713
|
+
const parent = get(obj, path.slice(0, -1), obj);
|
|
1714
|
+
const lastKey = path[path.length - 1];
|
|
1715
|
+
if (parent?.[lastKey] === undefined) {
|
|
1716
|
+
return true;
|
|
1717
|
+
}
|
|
1718
|
+
try {
|
|
1719
|
+
delete parent[lastKey];
|
|
1720
|
+
return true;
|
|
1721
|
+
}
|
|
1722
|
+
catch {
|
|
1723
|
+
return false;
|
|
1724
|
+
}
|
|
1414
1725
|
}
|
|
1415
1726
|
|
|
1416
|
-
function
|
|
1417
|
-
if (
|
|
1727
|
+
function omit(obj, ...keysArr) {
|
|
1728
|
+
if (obj == null) {
|
|
1418
1729
|
return {};
|
|
1419
1730
|
}
|
|
1420
|
-
const result =
|
|
1421
|
-
for (
|
|
1422
|
-
|
|
1731
|
+
const result = toMerged.cloneDeep(obj);
|
|
1732
|
+
for (let i = 0; i < keysArr.length; i++) {
|
|
1733
|
+
let keys = keysArr[i];
|
|
1734
|
+
switch (typeof keys) {
|
|
1735
|
+
case 'object': {
|
|
1736
|
+
if (!Array.isArray(keys)) {
|
|
1737
|
+
keys = Array.from(keys);
|
|
1738
|
+
}
|
|
1739
|
+
for (let j = 0; j < keys.length; j++) {
|
|
1740
|
+
const key = keys[j];
|
|
1741
|
+
unset(result, key);
|
|
1742
|
+
}
|
|
1743
|
+
break;
|
|
1744
|
+
}
|
|
1745
|
+
case 'string':
|
|
1746
|
+
case 'symbol':
|
|
1747
|
+
case 'number': {
|
|
1748
|
+
unset(result, keys);
|
|
1749
|
+
break;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1423
1752
|
}
|
|
1424
1753
|
return result;
|
|
1425
1754
|
}
|
|
1426
1755
|
|
|
1427
|
-
function
|
|
1428
|
-
return
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
function isError(value) {
|
|
1432
|
-
return isWeakSet$1.getTag(value) === '[object Error]';
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
function isFinite(value) {
|
|
1436
|
-
return Number.isFinite(value);
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
function isRegExp(value) {
|
|
1440
|
-
return isWeakSet$1.isRegExp(value);
|
|
1756
|
+
function isNil(x) {
|
|
1757
|
+
return x == null;
|
|
1441
1758
|
}
|
|
1442
1759
|
|
|
1443
|
-
function
|
|
1444
|
-
|
|
1760
|
+
function pick(obj, ...keysArr) {
|
|
1761
|
+
if (isNil(obj)) {
|
|
1762
|
+
return {};
|
|
1763
|
+
}
|
|
1764
|
+
const result = {};
|
|
1765
|
+
for (let i = 0; i < keysArr.length; i++) {
|
|
1766
|
+
let keys = keysArr[i];
|
|
1767
|
+
switch (typeof keys) {
|
|
1768
|
+
case 'object': {
|
|
1769
|
+
if (!Array.isArray(keys)) {
|
|
1770
|
+
keys = Array.from(keys);
|
|
1771
|
+
}
|
|
1772
|
+
break;
|
|
1773
|
+
}
|
|
1774
|
+
case 'string':
|
|
1775
|
+
case 'symbol':
|
|
1776
|
+
case 'number': {
|
|
1777
|
+
keys = [keys];
|
|
1778
|
+
break;
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
for (const key of keys) {
|
|
1782
|
+
const value = get(obj, key);
|
|
1783
|
+
if (typeof key === 'string' && Object.hasOwn(obj, key)) {
|
|
1784
|
+
result[key] = value;
|
|
1785
|
+
}
|
|
1786
|
+
else {
|
|
1787
|
+
set(result, key, value);
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
return result;
|
|
1445
1792
|
}
|
|
1446
1793
|
|
|
1447
|
-
function
|
|
1448
|
-
|
|
1794
|
+
function toDefaulted(object, ...sources) {
|
|
1795
|
+
const cloned = cloneDeep(object);
|
|
1796
|
+
return defaults(cloned, ...sources);
|
|
1449
1797
|
}
|
|
1450
1798
|
|
|
1451
1799
|
function conformsTo(target, source) {
|
|
@@ -1468,30 +1816,84 @@ function conformsTo(target, source) {
|
|
|
1468
1816
|
}
|
|
1469
1817
|
|
|
1470
1818
|
function conforms(source) {
|
|
1471
|
-
source =
|
|
1819
|
+
source = toMerged.cloneDeep(source);
|
|
1472
1820
|
return function (object) {
|
|
1473
1821
|
return conformsTo(object, source);
|
|
1474
1822
|
};
|
|
1475
1823
|
}
|
|
1476
1824
|
|
|
1825
|
+
function isArrayBuffer(value) {
|
|
1826
|
+
return isWeakSet$1.isArrayBuffer(value);
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
function isBoolean(value) {
|
|
1830
|
+
return typeof value === 'boolean' || value instanceof Boolean;
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
function isDate(value) {
|
|
1834
|
+
return isWeakSet$1.isDate(value);
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
function isEqualWith(a, b, areValuesEqual = noop.noop) {
|
|
1838
|
+
if (typeof areValuesEqual !== 'function') {
|
|
1839
|
+
areValuesEqual = noop.noop;
|
|
1840
|
+
}
|
|
1841
|
+
return isWeakSet$1.isEqualWith(a, b, (...args) => {
|
|
1842
|
+
const result = areValuesEqual(...args);
|
|
1843
|
+
if (result !== undefined) {
|
|
1844
|
+
return Boolean(result);
|
|
1845
|
+
}
|
|
1846
|
+
if (a instanceof Map && b instanceof Map) {
|
|
1847
|
+
return isEqualWith(Array.from(a), Array.from(b), unary.after(2, areValuesEqual));
|
|
1848
|
+
}
|
|
1849
|
+
if (a instanceof Set && b instanceof Set) {
|
|
1850
|
+
return isEqualWith(Array.from(a), Array.from(b), unary.after(2, areValuesEqual));
|
|
1851
|
+
}
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
function isError(value) {
|
|
1856
|
+
return isWeakSet$1.getTag(value) === '[object Error]';
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
function isFinite(value) {
|
|
1860
|
+
return Number.isFinite(value);
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1477
1863
|
function isInteger(value) {
|
|
1478
1864
|
return Number.isInteger(value);
|
|
1479
1865
|
}
|
|
1480
1866
|
|
|
1481
|
-
function
|
|
1482
|
-
return
|
|
1867
|
+
function isMap(value) {
|
|
1868
|
+
return isWeakSet$1.isMap(value);
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
function isNaN(value) {
|
|
1872
|
+
return Number.isNaN(value);
|
|
1483
1873
|
}
|
|
1484
1874
|
|
|
1485
1875
|
function isNumber(value) {
|
|
1486
1876
|
return typeof value === 'number' || value instanceof Number;
|
|
1487
1877
|
}
|
|
1488
1878
|
|
|
1489
|
-
function
|
|
1490
|
-
return
|
|
1879
|
+
function isRegExp(value) {
|
|
1880
|
+
return isWeakSet$1.isRegExp(value);
|
|
1491
1881
|
}
|
|
1492
1882
|
|
|
1493
|
-
function
|
|
1494
|
-
return
|
|
1883
|
+
function isSafeInteger(value) {
|
|
1884
|
+
return Number.isSafeInteger(value);
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
function isSet(value) {
|
|
1888
|
+
return isWeakSet$1.isSet(value);
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
function isWeakMap(value) {
|
|
1892
|
+
return isWeakSet$1.isWeakMap(value);
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
function isWeakSet(value) {
|
|
1896
|
+
return isWeakSet$1.isWeakSet(value);
|
|
1495
1897
|
}
|
|
1496
1898
|
|
|
1497
1899
|
function toString(value) {
|
|
@@ -1516,19 +1918,43 @@ function normalizeForCase(str) {
|
|
|
1516
1918
|
}
|
|
1517
1919
|
|
|
1518
1920
|
function camelCase(str) {
|
|
1519
|
-
return
|
|
1921
|
+
return upperFirst.camelCase(normalizeForCase(str));
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
function endsWith(str, target, position = str.length) {
|
|
1925
|
+
return str.endsWith(target, position);
|
|
1520
1926
|
}
|
|
1521
1927
|
|
|
1522
1928
|
function kebabCase(str) {
|
|
1523
|
-
return
|
|
1929
|
+
return upperFirst.kebabCase(normalizeForCase(str));
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
function lowerCase(str) {
|
|
1933
|
+
return upperFirst.lowerCase(normalizeForCase(str));
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
function pad(str, length, chars = ' ') {
|
|
1937
|
+
return upperFirst.pad(toString(str), length, chars);
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
function padEnd(str, length = 0, chars = ' ') {
|
|
1941
|
+
return toString(str).padEnd(length, chars);
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
function padStart(str, length = 0, chars = ' ') {
|
|
1945
|
+
return toString(str).padStart(length, chars);
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
function repeat(str, n) {
|
|
1949
|
+
return str.repeat(n);
|
|
1524
1950
|
}
|
|
1525
1951
|
|
|
1526
1952
|
function snakeCase(str) {
|
|
1527
|
-
return
|
|
1953
|
+
return upperFirst.snakeCase(normalizeForCase(str));
|
|
1528
1954
|
}
|
|
1529
1955
|
|
|
1530
1956
|
function startCase(str) {
|
|
1531
|
-
const words =
|
|
1957
|
+
const words = upperFirst.getWords(normalizeForCase(str).trim());
|
|
1532
1958
|
let result = '';
|
|
1533
1959
|
for (let i = 0; i < words.length; i++) {
|
|
1534
1960
|
const word = words[i];
|
|
@@ -1545,36 +1971,12 @@ function startCase(str) {
|
|
|
1545
1971
|
return result;
|
|
1546
1972
|
}
|
|
1547
1973
|
|
|
1548
|
-
function lowerCase(str) {
|
|
1549
|
-
return pad$1.lowerCase(normalizeForCase(str));
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
function upperCase(str) {
|
|
1553
|
-
return pad$1.upperCase(normalizeForCase(str));
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1556
1974
|
function startsWith(str, target, position = 0) {
|
|
1557
1975
|
return str.startsWith(target, position);
|
|
1558
1976
|
}
|
|
1559
1977
|
|
|
1560
|
-
function
|
|
1561
|
-
return
|
|
1562
|
-
}
|
|
1563
|
-
|
|
1564
|
-
function pad(str, length, chars = ' ') {
|
|
1565
|
-
return pad$1.pad(toString(str), length, chars);
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
function padStart(str, length = 0, chars = ' ') {
|
|
1569
|
-
return toString(str).padStart(length, chars);
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
function padEnd(str, length = 0, chars = ' ') {
|
|
1573
|
-
return toString(str).padEnd(length, chars);
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
function repeat(str, n) {
|
|
1577
|
-
return str.repeat(n);
|
|
1978
|
+
function upperCase(str) {
|
|
1979
|
+
return upperFirst.upperCase(normalizeForCase(str));
|
|
1578
1980
|
}
|
|
1579
1981
|
|
|
1580
1982
|
function trim(str, chars, guard) {
|
|
@@ -1586,224 +1988,94 @@ function trim(str, chars, guard) {
|
|
|
1586
1988
|
}
|
|
1587
1989
|
switch (typeof chars) {
|
|
1588
1990
|
case 'string': {
|
|
1589
|
-
return
|
|
1991
|
+
return upperFirst.trim(str, chars.toString().split(''));
|
|
1590
1992
|
}
|
|
1591
1993
|
case 'object': {
|
|
1592
1994
|
if (Array.isArray(chars)) {
|
|
1593
|
-
return
|
|
1995
|
+
return upperFirst.trim(str, chars.map(x => x.toString()));
|
|
1594
1996
|
}
|
|
1595
1997
|
else {
|
|
1596
|
-
return
|
|
1998
|
+
return upperFirst.trim(str, chars.toString().split(''));
|
|
1597
1999
|
}
|
|
1598
2000
|
}
|
|
1599
2001
|
}
|
|
1600
2002
|
}
|
|
1601
2003
|
|
|
1602
|
-
function
|
|
2004
|
+
function trimEnd(str, chars, guard) {
|
|
1603
2005
|
if (str == null) {
|
|
1604
2006
|
return '';
|
|
1605
2007
|
}
|
|
1606
2008
|
if (guard != null || chars == null) {
|
|
1607
|
-
return str.toString().
|
|
2009
|
+
return str.toString().trimEnd();
|
|
1608
2010
|
}
|
|
1609
2011
|
switch (typeof chars) {
|
|
1610
2012
|
case 'string': {
|
|
1611
|
-
return
|
|
2013
|
+
return upperFirst.trimEnd(str, chars.toString().split(''));
|
|
1612
2014
|
}
|
|
1613
2015
|
case 'object': {
|
|
1614
2016
|
if (Array.isArray(chars)) {
|
|
1615
|
-
return
|
|
2017
|
+
return upperFirst.trimEnd(str, chars.map(x => x.toString()));
|
|
1616
2018
|
}
|
|
1617
2019
|
else {
|
|
1618
|
-
return
|
|
2020
|
+
return upperFirst.trimEnd(str, chars.toString().split(''));
|
|
1619
2021
|
}
|
|
1620
2022
|
}
|
|
1621
2023
|
}
|
|
1622
2024
|
}
|
|
1623
2025
|
|
|
1624
|
-
function
|
|
2026
|
+
function trimStart(str, chars, guard) {
|
|
1625
2027
|
if (str == null) {
|
|
1626
2028
|
return '';
|
|
1627
2029
|
}
|
|
1628
2030
|
if (guard != null || chars == null) {
|
|
1629
|
-
return str.toString().
|
|
2031
|
+
return str.toString().trimStart();
|
|
1630
2032
|
}
|
|
1631
2033
|
switch (typeof chars) {
|
|
1632
2034
|
case 'string': {
|
|
1633
|
-
return
|
|
2035
|
+
return upperFirst.trimStart(str, chars.toString().split(''));
|
|
1634
2036
|
}
|
|
1635
2037
|
case 'object': {
|
|
1636
2038
|
if (Array.isArray(chars)) {
|
|
1637
|
-
return
|
|
2039
|
+
return upperFirst.trimStart(str, chars.map(x => x.toString()));
|
|
1638
2040
|
}
|
|
1639
2041
|
else {
|
|
1640
|
-
return
|
|
2042
|
+
return upperFirst.trimStart(str, chars.toString().split(''));
|
|
1641
2043
|
}
|
|
1642
2044
|
}
|
|
1643
2045
|
}
|
|
1644
2046
|
}
|
|
1645
2047
|
|
|
1646
|
-
function
|
|
1647
|
-
|
|
1648
|
-
bound1 = 0;
|
|
1649
|
-
}
|
|
1650
|
-
if (Number.isNaN(bound2)) {
|
|
1651
|
-
bound2 = 0;
|
|
1652
|
-
}
|
|
1653
|
-
return range.clamp(value, bound1, bound2);
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
|
-
function max(items = []) {
|
|
1657
|
-
let maxElement = items[0];
|
|
1658
|
-
let max = undefined;
|
|
1659
|
-
for (let i = 0; i < items.length; i++) {
|
|
1660
|
-
const element = items[i];
|
|
1661
|
-
if (max == null || element > max) {
|
|
1662
|
-
max = element;
|
|
1663
|
-
maxElement = element;
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
return maxElement;
|
|
2048
|
+
function constant(value) {
|
|
2049
|
+
return () => value;
|
|
1667
2050
|
}
|
|
1668
2051
|
|
|
1669
|
-
function
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
for (let i = 0; i < items.length; i++) {
|
|
1673
|
-
const element = items[i];
|
|
1674
|
-
if (min == null || element < min) {
|
|
1675
|
-
min = element;
|
|
1676
|
-
minElement = element;
|
|
1677
|
-
}
|
|
2052
|
+
function defaultTo(value, defaultValue) {
|
|
2053
|
+
if (value == null || Number.isNaN(value)) {
|
|
2054
|
+
return defaultValue;
|
|
1678
2055
|
}
|
|
1679
|
-
return
|
|
2056
|
+
return value;
|
|
1680
2057
|
}
|
|
1681
2058
|
|
|
1682
|
-
function
|
|
1683
|
-
|
|
1684
|
-
if (
|
|
1685
|
-
|
|
1686
|
-
}
|
|
1687
|
-
precision = Math.min(Number.parseInt(precision, 10), 292);
|
|
1688
|
-
if (precision) {
|
|
1689
|
-
const [magnitude, exponent = 0] = number.toString().split('e');
|
|
1690
|
-
let adjustedValue = Math[type](Number(`${magnitude}e${Number(exponent) + precision}`));
|
|
1691
|
-
if (Object.is(adjustedValue, -0)) {
|
|
1692
|
-
adjustedValue = '-0';
|
|
1693
|
-
}
|
|
1694
|
-
const [newMagnitude, newExponent = 0] = adjustedValue.toString().split('e');
|
|
1695
|
-
return Number(`${newMagnitude}e${Number(newExponent) - precision}`);
|
|
2059
|
+
function times(n, getValue) {
|
|
2060
|
+
n = toInteger(n);
|
|
2061
|
+
if (n < 1 || !Number.isSafeInteger(n)) {
|
|
2062
|
+
return [];
|
|
1696
2063
|
}
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
function ceil(number, precision = 0) {
|
|
1701
|
-
return decimalAdjust('ceil', number, precision);
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
function floor(number, precision = 0) {
|
|
1705
|
-
return decimalAdjust('floor', number, precision);
|
|
1706
|
-
}
|
|
1707
|
-
|
|
1708
|
-
function round(number, precision = 0) {
|
|
1709
|
-
return decimalAdjust('round', number, precision);
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
function parseInt(string, radix = 0, guard) {
|
|
1713
|
-
if (guard) {
|
|
1714
|
-
radix = 0;
|
|
2064
|
+
const result = new Array(n);
|
|
2065
|
+
for (let i = 0; i < n; i++) {
|
|
2066
|
+
result[i] = typeof getValue === 'function' ? getValue(i) : i;
|
|
1715
2067
|
}
|
|
1716
|
-
return
|
|
2068
|
+
return result;
|
|
1717
2069
|
}
|
|
1718
2070
|
|
|
1719
|
-
|
|
1720
|
-
if (!minimum) {
|
|
1721
|
-
minimum = 0;
|
|
1722
|
-
}
|
|
1723
|
-
if (maximum != null && !maximum) {
|
|
1724
|
-
maximum = 0;
|
|
1725
|
-
}
|
|
1726
|
-
if (minimum != null && typeof minimum !== 'number') {
|
|
1727
|
-
minimum = Number(minimum);
|
|
1728
|
-
}
|
|
1729
|
-
if (maximum == null && minimum === 0) {
|
|
1730
|
-
return false;
|
|
1731
|
-
}
|
|
1732
|
-
if (maximum != null && typeof maximum !== 'number') {
|
|
1733
|
-
maximum = Number(maximum);
|
|
1734
|
-
}
|
|
1735
|
-
if (maximum != null && minimum > maximum) {
|
|
1736
|
-
[minimum, maximum] = [maximum, minimum];
|
|
1737
|
-
}
|
|
1738
|
-
if (minimum === maximum) {
|
|
1739
|
-
return false;
|
|
1740
|
-
}
|
|
1741
|
-
return range.inRange(value, minimum, maximum);
|
|
1742
|
-
}
|
|
2071
|
+
const MAX_ARRAY_LENGTH = 4_294_967_295;
|
|
1743
2072
|
|
|
1744
|
-
function
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
let floating = false;
|
|
1748
|
-
switch (args.length) {
|
|
1749
|
-
case 1: {
|
|
1750
|
-
if (typeof args[0] === 'boolean') {
|
|
1751
|
-
floating = args[0];
|
|
1752
|
-
}
|
|
1753
|
-
else {
|
|
1754
|
-
maximum = args[0];
|
|
1755
|
-
}
|
|
1756
|
-
break;
|
|
1757
|
-
}
|
|
1758
|
-
case 2: {
|
|
1759
|
-
if (typeof args[1] === 'boolean') {
|
|
1760
|
-
maximum = args[0];
|
|
1761
|
-
floating = args[1];
|
|
1762
|
-
}
|
|
1763
|
-
else {
|
|
1764
|
-
minimum = args[0];
|
|
1765
|
-
maximum = args[1];
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
case 3: {
|
|
1769
|
-
if (typeof args[2] === 'object' && args[2] != null && args[2][args[1]] === args[0]) {
|
|
1770
|
-
minimum = 0;
|
|
1771
|
-
maximum = args[0];
|
|
1772
|
-
floating = false;
|
|
1773
|
-
}
|
|
1774
|
-
else {
|
|
1775
|
-
minimum = args[0];
|
|
1776
|
-
maximum = args[1];
|
|
1777
|
-
floating = args[2];
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
if (typeof minimum !== 'number') {
|
|
1782
|
-
minimum = Number(minimum);
|
|
1783
|
-
}
|
|
1784
|
-
if (typeof maximum !== 'number') {
|
|
1785
|
-
minimum = Number(maximum);
|
|
1786
|
-
}
|
|
1787
|
-
if (!minimum) {
|
|
1788
|
-
minimum = 0;
|
|
1789
|
-
}
|
|
1790
|
-
if (!maximum) {
|
|
1791
|
-
maximum = 0;
|
|
1792
|
-
}
|
|
1793
|
-
if (minimum > maximum) {
|
|
1794
|
-
[minimum, maximum] = [maximum, minimum];
|
|
1795
|
-
}
|
|
1796
|
-
minimum = clamp(minimum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
1797
|
-
maximum = clamp(maximum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
1798
|
-
if (minimum === maximum) {
|
|
1799
|
-
return minimum;
|
|
1800
|
-
}
|
|
1801
|
-
if (floating) {
|
|
1802
|
-
return randomInt.random(minimum, maximum + 1);
|
|
1803
|
-
}
|
|
1804
|
-
else {
|
|
1805
|
-
return randomInt.randomInt(minimum, maximum + 1);
|
|
2073
|
+
function toLength(value) {
|
|
2074
|
+
if (value == null) {
|
|
2075
|
+
return 0;
|
|
1806
2076
|
}
|
|
2077
|
+
const length = Math.floor(Number(value));
|
|
2078
|
+
return clamp(length, 0, MAX_ARRAY_LENGTH);
|
|
1807
2079
|
}
|
|
1808
2080
|
|
|
1809
2081
|
exports.at = zipWith.at;
|
|
@@ -1812,7 +2084,6 @@ exports.countBy = zipWith.countBy;
|
|
|
1812
2084
|
exports.differenceBy = zipWith.differenceBy;
|
|
1813
2085
|
exports.differenceWith = zipWith.differenceWith;
|
|
1814
2086
|
exports.dropRight = zipWith.dropRight;
|
|
1815
|
-
exports.dropRightWhile = zipWith.dropRightWhile;
|
|
1816
2087
|
exports.first = zipWith.head;
|
|
1817
2088
|
exports.flatMap = zipWith.flatMap;
|
|
1818
2089
|
exports.flatMapDeep = zipWith.flatMapDeep;
|
|
@@ -1834,7 +2105,6 @@ exports.sample = zipWith.sample;
|
|
|
1834
2105
|
exports.sampleSize = zipWith.sampleSize;
|
|
1835
2106
|
exports.shuffle = zipWith.shuffle;
|
|
1836
2107
|
exports.tail = zipWith.tail;
|
|
1837
|
-
exports.take = zipWith.take;
|
|
1838
2108
|
exports.takeRight = zipWith.takeRight;
|
|
1839
2109
|
exports.takeRightWhile = zipWith.takeRightWhile;
|
|
1840
2110
|
exports.takeWhile = zipWith.takeWhile;
|
|
@@ -1859,55 +2129,52 @@ exports.TimeoutError = promise_index.TimeoutError;
|
|
|
1859
2129
|
exports.delay = promise_index.delay;
|
|
1860
2130
|
exports.timeout = promise_index.timeout;
|
|
1861
2131
|
exports.withTimeout = promise_index.withTimeout;
|
|
1862
|
-
exports.after =
|
|
1863
|
-
exports.
|
|
1864
|
-
exports.
|
|
1865
|
-
exports.
|
|
1866
|
-
exports.
|
|
1867
|
-
exports.
|
|
1868
|
-
exports.
|
|
1869
|
-
exports.partialRight = flowRight$1.partialRight;
|
|
1870
|
-
exports.unary = flowRight$1.unary;
|
|
2132
|
+
exports.after = unary.after;
|
|
2133
|
+
exports.memoize = unary.memoize;
|
|
2134
|
+
exports.negate = unary.negate;
|
|
2135
|
+
exports.once = unary.once;
|
|
2136
|
+
exports.partial = unary.partial;
|
|
2137
|
+
exports.partialRight = unary.partialRight;
|
|
2138
|
+
exports.unary = unary.unary;
|
|
1871
2139
|
exports.noop = noop.noop;
|
|
1872
|
-
exports.mean =
|
|
1873
|
-
exports.meanBy =
|
|
1874
|
-
exports.range =
|
|
1875
|
-
exports.
|
|
1876
|
-
exports.
|
|
2140
|
+
exports.mean = sumBy.mean;
|
|
2141
|
+
exports.meanBy = sumBy.meanBy;
|
|
2142
|
+
exports.range = sumBy.range;
|
|
2143
|
+
exports.rangeRight = sumBy.rangeRight;
|
|
2144
|
+
exports.sum = sumBy.sum;
|
|
2145
|
+
exports.sumBy = sumBy.sumBy;
|
|
1877
2146
|
exports.randomInt = randomInt.randomInt;
|
|
1878
|
-
exports.clone =
|
|
1879
|
-
exports.flattenObject =
|
|
1880
|
-
exports.invert =
|
|
1881
|
-
exports.isObjectLike =
|
|
1882
|
-
exports.omitBy =
|
|
1883
|
-
exports.pickBy =
|
|
1884
|
-
exports.toMerged =
|
|
2147
|
+
exports.clone = toMerged.clone;
|
|
2148
|
+
exports.flattenObject = toMerged.flattenObject;
|
|
2149
|
+
exports.invert = toMerged.invert;
|
|
2150
|
+
exports.isObjectLike = toMerged.isObjectLike;
|
|
2151
|
+
exports.omitBy = toMerged.omitBy;
|
|
2152
|
+
exports.pickBy = toMerged.pickBy;
|
|
2153
|
+
exports.toMerged = toMerged.toMerged;
|
|
1885
2154
|
exports.isPrimitive = isPlainObject$1.isPrimitive;
|
|
1886
|
-
exports.
|
|
1887
|
-
exports.
|
|
2155
|
+
exports.eq = isWeakSet$1.eq;
|
|
2156
|
+
exports.isBlob = isWeakSet$1.isBlob;
|
|
1888
2157
|
exports.isEqual = isWeakSet$1.isEqual;
|
|
1889
|
-
exports.isEqualWith = isWeakSet$1.isEqualWith;
|
|
1890
2158
|
exports.isFunction = isWeakSet$1.isFunction;
|
|
1891
2159
|
exports.isJSONArray = isWeakSet$1.isJSONArray;
|
|
1892
2160
|
exports.isJSONObject = isWeakSet$1.isJSONObject;
|
|
1893
2161
|
exports.isJSONValue = isWeakSet$1.isJSONValue;
|
|
1894
2162
|
exports.isLength = isWeakSet$1.isLength;
|
|
1895
|
-
exports.isMap = isWeakSet$1.isMap;
|
|
1896
2163
|
exports.isNotNil = isWeakSet$1.isNotNil;
|
|
1897
2164
|
exports.isNull = isWeakSet$1.isNull;
|
|
1898
|
-
exports.isSet = isWeakSet$1.isSet;
|
|
1899
2165
|
exports.isUndefined = isWeakSet$1.isUndefined;
|
|
1900
|
-
exports.capitalize =
|
|
1901
|
-
exports.constantCase =
|
|
1902
|
-
exports.deburr =
|
|
1903
|
-
exports.escape =
|
|
1904
|
-
exports.escapeRegExp =
|
|
1905
|
-
exports.lowerFirst =
|
|
1906
|
-
exports.pascalCase =
|
|
1907
|
-
exports.unescape =
|
|
1908
|
-
exports.upperFirst =
|
|
2166
|
+
exports.capitalize = upperFirst.capitalize;
|
|
2167
|
+
exports.constantCase = upperFirst.constantCase;
|
|
2168
|
+
exports.deburr = upperFirst.deburr;
|
|
2169
|
+
exports.escape = upperFirst.escape;
|
|
2170
|
+
exports.escapeRegExp = upperFirst.escapeRegExp;
|
|
2171
|
+
exports.lowerFirst = upperFirst.lowerFirst;
|
|
2172
|
+
exports.pascalCase = upperFirst.pascalCase;
|
|
2173
|
+
exports.unescape = upperFirst.unescape;
|
|
2174
|
+
exports.upperFirst = upperFirst.upperFirst;
|
|
1909
2175
|
exports.ary = ary;
|
|
1910
2176
|
exports.attempt = attempt;
|
|
2177
|
+
exports.before = before;
|
|
1911
2178
|
exports.bind = bind;
|
|
1912
2179
|
exports.bindKey = bindKey;
|
|
1913
2180
|
exports.camelCase = camelCase;
|
|
@@ -1919,11 +2186,16 @@ exports.cloneDeep = cloneDeep;
|
|
|
1919
2186
|
exports.concat = concat;
|
|
1920
2187
|
exports.conforms = conforms;
|
|
1921
2188
|
exports.conformsTo = conformsTo;
|
|
2189
|
+
exports.constant = constant;
|
|
1922
2190
|
exports.curry = curry;
|
|
2191
|
+
exports.curryRight = curryRight;
|
|
1923
2192
|
exports.debounce = debounce;
|
|
2193
|
+
exports.defaultTo = defaultTo;
|
|
2194
|
+
exports.defaults = defaults;
|
|
1924
2195
|
exports.defer = defer;
|
|
1925
2196
|
exports.difference = difference;
|
|
1926
2197
|
exports.drop = drop;
|
|
2198
|
+
exports.dropRightWhile = dropRightWhile;
|
|
1927
2199
|
exports.dropWhile = dropWhile;
|
|
1928
2200
|
exports.endsWith = endsWith;
|
|
1929
2201
|
exports.every = every;
|
|
@@ -1945,14 +2217,19 @@ exports.has = has;
|
|
|
1945
2217
|
exports.inRange = inRange;
|
|
1946
2218
|
exports.includes = includes;
|
|
1947
2219
|
exports.indexOf = indexOf;
|
|
2220
|
+
exports.invertBy = invertBy;
|
|
1948
2221
|
exports.isArguments = isArguments;
|
|
1949
2222
|
exports.isArray = isArray;
|
|
2223
|
+
exports.isArrayBuffer = isArrayBuffer;
|
|
1950
2224
|
exports.isArrayLike = isArrayLike;
|
|
1951
2225
|
exports.isArrayLikeObject = isArrayLikeObject;
|
|
1952
2226
|
exports.isBoolean = isBoolean;
|
|
2227
|
+
exports.isDate = isDate;
|
|
2228
|
+
exports.isEqualWith = isEqualWith;
|
|
1953
2229
|
exports.isError = isError;
|
|
1954
2230
|
exports.isFinite = isFinite;
|
|
1955
2231
|
exports.isInteger = isInteger;
|
|
2232
|
+
exports.isMap = isMap;
|
|
1956
2233
|
exports.isMatch = isMatch;
|
|
1957
2234
|
exports.isNaN = isNaN;
|
|
1958
2235
|
exports.isNil = isNil;
|
|
@@ -1961,6 +2238,7 @@ exports.isObject = isObject;
|
|
|
1961
2238
|
exports.isPlainObject = isPlainObject;
|
|
1962
2239
|
exports.isRegExp = isRegExp;
|
|
1963
2240
|
exports.isSafeInteger = isSafeInteger;
|
|
2241
|
+
exports.isSet = isSet;
|
|
1964
2242
|
exports.isString = isString;
|
|
1965
2243
|
exports.isSymbol = isSymbol;
|
|
1966
2244
|
exports.isTypedArray = isTypedArray;
|
|
@@ -1992,15 +2270,20 @@ exports.rest = rest;
|
|
|
1992
2270
|
exports.round = round;
|
|
1993
2271
|
exports.set = set;
|
|
1994
2272
|
exports.size = size;
|
|
2273
|
+
exports.slice = slice;
|
|
1995
2274
|
exports.snakeCase = snakeCase;
|
|
1996
2275
|
exports.some = some;
|
|
1997
2276
|
exports.sortBy = sortBy;
|
|
1998
2277
|
exports.spread = spread;
|
|
1999
2278
|
exports.startCase = startCase;
|
|
2000
2279
|
exports.startsWith = startsWith;
|
|
2280
|
+
exports.take = take;
|
|
2001
2281
|
exports.throttle = throttle;
|
|
2282
|
+
exports.times = times;
|
|
2283
|
+
exports.toDefaulted = toDefaulted;
|
|
2002
2284
|
exports.toFinite = toFinite;
|
|
2003
2285
|
exports.toInteger = toInteger;
|
|
2286
|
+
exports.toLength = toLength;
|
|
2004
2287
|
exports.toNumber = toNumber;
|
|
2005
2288
|
exports.toPath = toPath;
|
|
2006
2289
|
exports.toString = toString;
|