@vinicunca/perkakas 0.0.5 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +201 -225
- package/dist/index.d.cts +58 -49
- package/dist/index.d.ts +58 -49
- package/dist/index.js +200 -223
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,6 @@ __export(src_exports, {
|
|
|
30
30
|
clone: () => clone,
|
|
31
31
|
compact: () => compact,
|
|
32
32
|
concat: () => concat,
|
|
33
|
-
convertToUnit: () => convertToUnit,
|
|
34
33
|
countBy: () => countBy,
|
|
35
34
|
createPipe: () => createPipe,
|
|
36
35
|
difference: () => difference,
|
|
@@ -54,7 +53,6 @@ __export(src_exports, {
|
|
|
54
53
|
groupBy: () => groupBy,
|
|
55
54
|
humanReadableFileSize: () => humanReadableFileSize,
|
|
56
55
|
identity: () => identity,
|
|
57
|
-
increaseWithUnit: () => increaseWithUnit,
|
|
58
56
|
indexBy: () => indexBy,
|
|
59
57
|
intersection: () => intersection,
|
|
60
58
|
intersectionWith: () => intersectionWith,
|
|
@@ -110,6 +108,7 @@ __export(src_exports, {
|
|
|
110
108
|
setPath: () => setPath,
|
|
111
109
|
shuffle: () => shuffle,
|
|
112
110
|
sleep: () => sleep,
|
|
111
|
+
slugify: () => slugify,
|
|
113
112
|
sort: () => sort,
|
|
114
113
|
sortBy: () => sortBy,
|
|
115
114
|
splitAt: () => splitAt,
|
|
@@ -313,25 +312,32 @@ function purry(fn, args, lazy) {
|
|
|
313
312
|
throw new Error("Wrong number of arguments");
|
|
314
313
|
}
|
|
315
314
|
|
|
315
|
+
// src/function/sleep.ts
|
|
316
|
+
function sleep(timeout) {
|
|
317
|
+
return new Promise((resolve) => {
|
|
318
|
+
setTimeout(resolve, timeout);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
316
322
|
// src/array/all-pass.ts
|
|
317
|
-
function allPass() {
|
|
318
|
-
return purry(_allPass,
|
|
323
|
+
function allPass(...args) {
|
|
324
|
+
return purry(_allPass, args);
|
|
319
325
|
}
|
|
320
326
|
function _allPass(data, fns) {
|
|
321
327
|
return fns.every((fn) => fn(data));
|
|
322
328
|
}
|
|
323
329
|
|
|
324
330
|
// src/array/any-pass.ts
|
|
325
|
-
function anyPass() {
|
|
326
|
-
return purry(_anyPass,
|
|
331
|
+
function anyPass(...args) {
|
|
332
|
+
return purry(_anyPass, args);
|
|
327
333
|
}
|
|
328
334
|
function _anyPass(data, fns) {
|
|
329
335
|
return fns.some((fn) => fn(data));
|
|
330
336
|
}
|
|
331
337
|
|
|
332
338
|
// src/array/chunk.ts
|
|
333
|
-
function chunk() {
|
|
334
|
-
return purry(_chunk,
|
|
339
|
+
function chunk(...args) {
|
|
340
|
+
return purry(_chunk, args);
|
|
335
341
|
}
|
|
336
342
|
function _chunk(array, size) {
|
|
337
343
|
const ret = Array.from({
|
|
@@ -446,8 +452,8 @@ function compact(items) {
|
|
|
446
452
|
}
|
|
447
453
|
|
|
448
454
|
// src/array/concat.ts
|
|
449
|
-
function concat() {
|
|
450
|
-
return purry(_concat,
|
|
455
|
+
function concat(...args) {
|
|
456
|
+
return purry(_concat, args);
|
|
451
457
|
}
|
|
452
458
|
function _concat(arr1, arr2) {
|
|
453
459
|
return arr1.concat(arr2);
|
|
@@ -462,12 +468,12 @@ function _countBy(indexed) {
|
|
|
462
468
|
}, 0);
|
|
463
469
|
};
|
|
464
470
|
}
|
|
465
|
-
function countBy() {
|
|
466
|
-
return purry(_countBy(false),
|
|
471
|
+
function countBy(...args) {
|
|
472
|
+
return purry(_countBy(false), args);
|
|
467
473
|
}
|
|
468
474
|
((countBy2) => {
|
|
469
|
-
function indexed() {
|
|
470
|
-
return purry(_countBy(true),
|
|
475
|
+
function indexed(...args) {
|
|
476
|
+
return purry(_countBy(true), args);
|
|
471
477
|
}
|
|
472
478
|
countBy2.indexed = indexed;
|
|
473
479
|
})(countBy || (countBy = {}));
|
|
@@ -488,8 +494,8 @@ function _reduceLazy(array, lazy, indexed) {
|
|
|
488
494
|
}
|
|
489
495
|
|
|
490
496
|
// src/array/difference-with.ts
|
|
491
|
-
function differenceWith() {
|
|
492
|
-
return purry(_differenceWith,
|
|
497
|
+
function differenceWith(...args) {
|
|
498
|
+
return purry(_differenceWith, args, differenceWith.lazy);
|
|
493
499
|
}
|
|
494
500
|
function _differenceWith(array, other, isEquals) {
|
|
495
501
|
const lazy = differenceWith.lazy(other, isEquals);
|
|
@@ -515,8 +521,8 @@ function _differenceWith(array, other, isEquals) {
|
|
|
515
521
|
})(differenceWith || (differenceWith = {}));
|
|
516
522
|
|
|
517
523
|
// src/array/difference.ts
|
|
518
|
-
function difference() {
|
|
519
|
-
return purry(_difference,
|
|
524
|
+
function difference(...args) {
|
|
525
|
+
return purry(_difference, args, difference.lazy);
|
|
520
526
|
}
|
|
521
527
|
function _difference(array, other) {
|
|
522
528
|
const lazy = difference.lazy(other);
|
|
@@ -543,8 +549,8 @@ function _difference(array, other) {
|
|
|
543
549
|
})(difference || (difference = {}));
|
|
544
550
|
|
|
545
551
|
// src/array/drop-last.ts
|
|
546
|
-
function dropLast() {
|
|
547
|
-
return purry(_dropLast,
|
|
552
|
+
function dropLast(...args) {
|
|
553
|
+
return purry(_dropLast, args);
|
|
548
554
|
}
|
|
549
555
|
function _dropLast(array, n) {
|
|
550
556
|
const copy = [...array];
|
|
@@ -555,8 +561,8 @@ function _dropLast(array, n) {
|
|
|
555
561
|
}
|
|
556
562
|
|
|
557
563
|
// src/array/drop.ts
|
|
558
|
-
function drop() {
|
|
559
|
-
return purry(_drop,
|
|
564
|
+
function drop(...args) {
|
|
565
|
+
return purry(_drop, args, drop.lazy);
|
|
560
566
|
}
|
|
561
567
|
function _drop(array, n) {
|
|
562
568
|
return _reduceLazy(array, drop.lazy(n));
|
|
@@ -589,8 +595,8 @@ function toLazyIndexed(fn) {
|
|
|
589
595
|
}
|
|
590
596
|
|
|
591
597
|
// src/array/filter.ts
|
|
592
|
-
function filter() {
|
|
593
|
-
return purry(_filter(false),
|
|
598
|
+
function filter(...args) {
|
|
599
|
+
return purry(_filter(false), args, filter.lazy);
|
|
594
600
|
}
|
|
595
601
|
function _filter(indexed) {
|
|
596
602
|
return (array, fn) => {
|
|
@@ -620,8 +626,8 @@ function _lazy(indexed) {
|
|
|
620
626
|
};
|
|
621
627
|
}
|
|
622
628
|
((filter2) => {
|
|
623
|
-
function indexed() {
|
|
624
|
-
return purry(_filter(true),
|
|
629
|
+
function indexed(...args) {
|
|
630
|
+
return purry(_filter(true), args, filter2.lazyIndexed);
|
|
625
631
|
}
|
|
626
632
|
filter2.indexed = indexed;
|
|
627
633
|
filter2.lazy = _lazy(false);
|
|
@@ -635,8 +641,8 @@ function toSingle(fn) {
|
|
|
635
641
|
}
|
|
636
642
|
|
|
637
643
|
// src/array/find-index.ts
|
|
638
|
-
function findIndex() {
|
|
639
|
-
return purry(_findIndex(false),
|
|
644
|
+
function findIndex(...args) {
|
|
645
|
+
return purry(_findIndex(false), args, findIndex.lazy);
|
|
640
646
|
}
|
|
641
647
|
function _findIndex(indexed) {
|
|
642
648
|
return (array, fn) => {
|
|
@@ -667,8 +673,8 @@ function _lazy2(indexed) {
|
|
|
667
673
|
};
|
|
668
674
|
}
|
|
669
675
|
((findIndex2) => {
|
|
670
|
-
function indexed() {
|
|
671
|
-
return purry(_findIndex(true),
|
|
676
|
+
function indexed(...args) {
|
|
677
|
+
return purry(_findIndex(true), args, findIndex2.lazyIndexed);
|
|
672
678
|
}
|
|
673
679
|
findIndex2.indexed = indexed;
|
|
674
680
|
findIndex2.lazy = toSingle(_lazy2(false));
|
|
@@ -676,8 +682,8 @@ function _lazy2(indexed) {
|
|
|
676
682
|
})(findIndex || (findIndex = {}));
|
|
677
683
|
|
|
678
684
|
// src/array/find-last-index.ts
|
|
679
|
-
function findLastIndex() {
|
|
680
|
-
return purry(_findLastIndex(false),
|
|
685
|
+
function findLastIndex(...args) {
|
|
686
|
+
return purry(_findLastIndex(false), args);
|
|
681
687
|
}
|
|
682
688
|
function _findLastIndex(indexed) {
|
|
683
689
|
return (array, fn) => {
|
|
@@ -690,15 +696,15 @@ function _findLastIndex(indexed) {
|
|
|
690
696
|
};
|
|
691
697
|
}
|
|
692
698
|
((findLastIndex2) => {
|
|
693
|
-
function indexed() {
|
|
694
|
-
return purry(_findLastIndex(true),
|
|
699
|
+
function indexed(...args) {
|
|
700
|
+
return purry(_findLastIndex(true), args);
|
|
695
701
|
}
|
|
696
702
|
findLastIndex2.indexed = indexed;
|
|
697
703
|
})(findLastIndex || (findLastIndex = {}));
|
|
698
704
|
|
|
699
705
|
// src/array/find-last.ts
|
|
700
|
-
function findLast() {
|
|
701
|
-
return purry(_findLast(false),
|
|
706
|
+
function findLast(...args) {
|
|
707
|
+
return purry(_findLast(false), args);
|
|
702
708
|
}
|
|
703
709
|
function _findLast(indexed) {
|
|
704
710
|
return (array, fn) => {
|
|
@@ -710,15 +716,15 @@ function _findLast(indexed) {
|
|
|
710
716
|
};
|
|
711
717
|
}
|
|
712
718
|
((findLast2) => {
|
|
713
|
-
function indexed() {
|
|
714
|
-
return purry(_findLast(true),
|
|
719
|
+
function indexed(...args) {
|
|
720
|
+
return purry(_findLast(true), args);
|
|
715
721
|
}
|
|
716
722
|
findLast2.indexed = indexed;
|
|
717
723
|
})(findLast || (findLast = {}));
|
|
718
724
|
|
|
719
725
|
// src/array/find.ts
|
|
720
|
-
function find() {
|
|
721
|
-
return purry(_find(false),
|
|
726
|
+
function find(...args) {
|
|
727
|
+
return purry(_find(false), args, find.lazy);
|
|
722
728
|
}
|
|
723
729
|
function _find(indexed) {
|
|
724
730
|
return (array, fn) => {
|
|
@@ -741,8 +747,8 @@ function _lazy3(indexed) {
|
|
|
741
747
|
};
|
|
742
748
|
}
|
|
743
749
|
((find2) => {
|
|
744
|
-
function indexed() {
|
|
745
|
-
return purry(_find(true),
|
|
750
|
+
function indexed(...args) {
|
|
751
|
+
return purry(_find(true), args, find2.lazyIndexed);
|
|
746
752
|
}
|
|
747
753
|
find2.indexed = indexed;
|
|
748
754
|
find2.lazy = toSingle(_lazy3(false));
|
|
@@ -750,8 +756,8 @@ function _lazy3(indexed) {
|
|
|
750
756
|
})(find || (find = {}));
|
|
751
757
|
|
|
752
758
|
// src/array/first.ts
|
|
753
|
-
function first() {
|
|
754
|
-
return purry(_first,
|
|
759
|
+
function first(...args) {
|
|
760
|
+
return purry(_first, args, first.lazy);
|
|
755
761
|
}
|
|
756
762
|
function _first([first2]) {
|
|
757
763
|
return first2;
|
|
@@ -773,8 +779,8 @@ function _first([first2]) {
|
|
|
773
779
|
})(first || (first = {}));
|
|
774
780
|
|
|
775
781
|
// src/array/flat-map-to-obj.ts
|
|
776
|
-
function flatMapToObj() {
|
|
777
|
-
return purry(_flatMapToObj(false),
|
|
782
|
+
function flatMapToObj(...args) {
|
|
783
|
+
return purry(_flatMapToObj(false), args);
|
|
778
784
|
}
|
|
779
785
|
function _flatMapToObj(indexed) {
|
|
780
786
|
return (array, fn) => {
|
|
@@ -788,15 +794,15 @@ function _flatMapToObj(indexed) {
|
|
|
788
794
|
};
|
|
789
795
|
}
|
|
790
796
|
((flatMapToObj2) => {
|
|
791
|
-
function indexed() {
|
|
792
|
-
return purry(_flatMapToObj(true),
|
|
797
|
+
function indexed(...args) {
|
|
798
|
+
return purry(_flatMapToObj(true), args);
|
|
793
799
|
}
|
|
794
800
|
flatMapToObj2.indexed = indexed;
|
|
795
801
|
})(flatMapToObj || (flatMapToObj = {}));
|
|
796
802
|
|
|
797
803
|
// src/array/flatten.ts
|
|
798
|
-
function flatten() {
|
|
799
|
-
return purry(_flatten,
|
|
804
|
+
function flatten(...args) {
|
|
805
|
+
return purry(_flatten, args, flatten.lazy);
|
|
800
806
|
}
|
|
801
807
|
function _flatten(items) {
|
|
802
808
|
return _reduceLazy(items, flatten.lazy());
|
|
@@ -823,8 +829,8 @@ function _flatten(items) {
|
|
|
823
829
|
})(flatten || (flatten = {}));
|
|
824
830
|
|
|
825
831
|
// src/array/flat-map.ts
|
|
826
|
-
function flatMap() {
|
|
827
|
-
return purry(_flatMap,
|
|
832
|
+
function flatMap(...args) {
|
|
833
|
+
return purry(_flatMap, args, flatMap.lazy);
|
|
828
834
|
}
|
|
829
835
|
function _flatMap(array, fn) {
|
|
830
836
|
return flatten(array.map((item) => fn(item)));
|
|
@@ -852,8 +858,8 @@ function _flatMap(array, fn) {
|
|
|
852
858
|
})(flatMap || (flatMap = {}));
|
|
853
859
|
|
|
854
860
|
// src/array/flatten-deep.ts
|
|
855
|
-
function flattenDeep() {
|
|
856
|
-
return purry(_flattenDeep,
|
|
861
|
+
function flattenDeep(...args) {
|
|
862
|
+
return purry(_flattenDeep, args, flattenDeep.lazy);
|
|
857
863
|
}
|
|
858
864
|
function _flattenDeep(items) {
|
|
859
865
|
return _reduceLazy(items, flattenDeep.lazy());
|
|
@@ -895,8 +901,8 @@ function _flattenDeepValue(value) {
|
|
|
895
901
|
})(flattenDeep || (flattenDeep = {}));
|
|
896
902
|
|
|
897
903
|
// src/array/for-each.ts
|
|
898
|
-
function forEach() {
|
|
899
|
-
return purry(_forEach(false),
|
|
904
|
+
function forEach(...args) {
|
|
905
|
+
return purry(_forEach(false), args, forEach.lazy);
|
|
900
906
|
}
|
|
901
907
|
function _forEach(indexed) {
|
|
902
908
|
return (array, fn) => {
|
|
@@ -924,8 +930,8 @@ function _lazy4(indexed) {
|
|
|
924
930
|
};
|
|
925
931
|
}
|
|
926
932
|
((forEach2) => {
|
|
927
|
-
function indexed() {
|
|
928
|
-
return purry(_forEach(true),
|
|
933
|
+
function indexed(...args) {
|
|
934
|
+
return purry(_forEach(true), args, forEach2.lazyIndexed);
|
|
929
935
|
}
|
|
930
936
|
forEach2.indexed = indexed;
|
|
931
937
|
forEach2.lazy = _lazy4(false);
|
|
@@ -933,8 +939,8 @@ function _lazy4(indexed) {
|
|
|
933
939
|
})(forEach || (forEach = {}));
|
|
934
940
|
|
|
935
941
|
// src/array/group-by.ts
|
|
936
|
-
function groupBy() {
|
|
937
|
-
return purry(_groupBy(false),
|
|
942
|
+
function groupBy(...args) {
|
|
943
|
+
return purry(_groupBy(false), args);
|
|
938
944
|
}
|
|
939
945
|
function _groupBy(indexed) {
|
|
940
946
|
return (array, fn) => {
|
|
@@ -953,16 +959,16 @@ function _groupBy(indexed) {
|
|
|
953
959
|
};
|
|
954
960
|
}
|
|
955
961
|
((groupBy2) => {
|
|
956
|
-
function indexed() {
|
|
957
|
-
return purry(_groupBy(true),
|
|
962
|
+
function indexed(...args) {
|
|
963
|
+
return purry(_groupBy(true), args);
|
|
958
964
|
}
|
|
959
965
|
groupBy2.indexed = indexed;
|
|
960
966
|
groupBy2.strict = groupBy2;
|
|
961
967
|
})(groupBy || (groupBy = {}));
|
|
962
968
|
|
|
963
969
|
// src/array/index-by.ts
|
|
964
|
-
function indexBy() {
|
|
965
|
-
return purry(_indexBy(false),
|
|
970
|
+
function indexBy(...args) {
|
|
971
|
+
return purry(_indexBy(false), args);
|
|
966
972
|
}
|
|
967
973
|
function _indexBy(indexed) {
|
|
968
974
|
return (array, fn) => {
|
|
@@ -975,15 +981,15 @@ function _indexBy(indexed) {
|
|
|
975
981
|
};
|
|
976
982
|
}
|
|
977
983
|
((indexBy2) => {
|
|
978
|
-
function indexed() {
|
|
979
|
-
return purry(_indexBy(true),
|
|
984
|
+
function indexed(...args) {
|
|
985
|
+
return purry(_indexBy(true), args);
|
|
980
986
|
}
|
|
981
987
|
indexBy2.indexed = indexed;
|
|
982
988
|
})(indexBy || (indexBy = {}));
|
|
983
989
|
|
|
984
990
|
// src/array/intersection.ts
|
|
985
|
-
function intersection() {
|
|
986
|
-
return purry(_intersection,
|
|
991
|
+
function intersection(...args) {
|
|
992
|
+
return purry(_intersection, args, intersection.lazy);
|
|
987
993
|
}
|
|
988
994
|
function _intersection(array, other) {
|
|
989
995
|
const lazy = intersection.lazy(other);
|
|
@@ -1010,8 +1016,8 @@ function _intersection(array, other) {
|
|
|
1010
1016
|
})(intersection || (intersection = {}));
|
|
1011
1017
|
|
|
1012
1018
|
// src/array/intersection-with.ts
|
|
1013
|
-
function intersectionWith() {
|
|
1014
|
-
return purry(_intersectionWith,
|
|
1019
|
+
function intersectionWith(...args) {
|
|
1020
|
+
return purry(_intersectionWith, args, intersectionWith.lazy);
|
|
1015
1021
|
}
|
|
1016
1022
|
function _intersectionWith(array, other, comparator) {
|
|
1017
1023
|
const lazy = intersectionWith.lazy(other, comparator);
|
|
@@ -1037,32 +1043,32 @@ function _intersectionWith(array, other, comparator) {
|
|
|
1037
1043
|
})(intersectionWith || (intersectionWith = {}));
|
|
1038
1044
|
|
|
1039
1045
|
// src/array/join.ts
|
|
1040
|
-
function join() {
|
|
1041
|
-
return purry(joinImplementation,
|
|
1046
|
+
function join(...args) {
|
|
1047
|
+
return purry(joinImplementation, args);
|
|
1042
1048
|
}
|
|
1043
1049
|
function joinImplementation(data, glue) {
|
|
1044
1050
|
return data.join(glue);
|
|
1045
1051
|
}
|
|
1046
1052
|
|
|
1047
1053
|
// src/array/last.ts
|
|
1048
|
-
function last() {
|
|
1049
|
-
return purry(_last,
|
|
1054
|
+
function last(...args) {
|
|
1055
|
+
return purry(_last, args);
|
|
1050
1056
|
}
|
|
1051
1057
|
function _last(array) {
|
|
1052
1058
|
return array[array.length - 1];
|
|
1053
1059
|
}
|
|
1054
1060
|
|
|
1055
1061
|
// src/array/length.ts
|
|
1056
|
-
function length() {
|
|
1057
|
-
return purry(_length,
|
|
1062
|
+
function length(...args) {
|
|
1063
|
+
return purry(_length, args);
|
|
1058
1064
|
}
|
|
1059
1065
|
function _length(items) {
|
|
1060
1066
|
return "length" in items ? items.length : Array.from(items).length;
|
|
1061
1067
|
}
|
|
1062
1068
|
|
|
1063
1069
|
// src/array/map.ts
|
|
1064
|
-
function map() {
|
|
1065
|
-
return purry(_map(false),
|
|
1070
|
+
function map(...args) {
|
|
1071
|
+
return purry(_map(false), args, map.lazy);
|
|
1066
1072
|
}
|
|
1067
1073
|
function _map(indexed) {
|
|
1068
1074
|
return (array, fn) => {
|
|
@@ -1085,8 +1091,8 @@ function _lazy5(indexed) {
|
|
|
1085
1091
|
};
|
|
1086
1092
|
}
|
|
1087
1093
|
((map2) => {
|
|
1088
|
-
function indexed() {
|
|
1089
|
-
return purry(_map(true),
|
|
1094
|
+
function indexed(...args) {
|
|
1095
|
+
return purry(_map(true), args, map2.lazyIndexed);
|
|
1090
1096
|
}
|
|
1091
1097
|
map2.indexed = indexed;
|
|
1092
1098
|
map2.lazy = _lazy5(false);
|
|
@@ -1095,8 +1101,8 @@ function _lazy5(indexed) {
|
|
|
1095
1101
|
})(map || (map = {}));
|
|
1096
1102
|
|
|
1097
1103
|
// src/array/map-to-obj.ts
|
|
1098
|
-
function mapToObj() {
|
|
1099
|
-
return purry(_mapToObj(false),
|
|
1104
|
+
function mapToObj(...args) {
|
|
1105
|
+
return purry(_mapToObj(false), args);
|
|
1100
1106
|
}
|
|
1101
1107
|
function _mapToObj(indexed) {
|
|
1102
1108
|
return (array, fn) => {
|
|
@@ -1108,8 +1114,8 @@ function _mapToObj(indexed) {
|
|
|
1108
1114
|
};
|
|
1109
1115
|
}
|
|
1110
1116
|
((mapToObj2) => {
|
|
1111
|
-
function indexed() {
|
|
1112
|
-
return purry(_mapToObj(true),
|
|
1117
|
+
function indexed(...args) {
|
|
1118
|
+
return purry(_mapToObj(true), args);
|
|
1113
1119
|
}
|
|
1114
1120
|
mapToObj2.indexed = indexed;
|
|
1115
1121
|
})(mapToObj || (mapToObj = {}));
|
|
@@ -1129,12 +1135,12 @@ function _maxBy(indexed) {
|
|
|
1129
1135
|
return ret;
|
|
1130
1136
|
};
|
|
1131
1137
|
}
|
|
1132
|
-
function maxBy() {
|
|
1133
|
-
return purry(_maxBy(false),
|
|
1138
|
+
function maxBy(...args) {
|
|
1139
|
+
return purry(_maxBy(false), args);
|
|
1134
1140
|
}
|
|
1135
1141
|
((maxBy2) => {
|
|
1136
|
-
function indexed() {
|
|
1137
|
-
return purry(_maxBy(true),
|
|
1142
|
+
function indexed(...args) {
|
|
1143
|
+
return purry(_maxBy(true), args);
|
|
1138
1144
|
}
|
|
1139
1145
|
maxBy2.indexed = indexed;
|
|
1140
1146
|
})(maxBy || (maxBy = {}));
|
|
@@ -1152,12 +1158,12 @@ function _meanBy(indexed) {
|
|
|
1152
1158
|
return sum / array.length;
|
|
1153
1159
|
};
|
|
1154
1160
|
}
|
|
1155
|
-
function meanBy() {
|
|
1156
|
-
return purry(_meanBy(false),
|
|
1161
|
+
function meanBy(...args) {
|
|
1162
|
+
return purry(_meanBy(false), args);
|
|
1157
1163
|
}
|
|
1158
1164
|
((meanBy2) => {
|
|
1159
|
-
function indexed() {
|
|
1160
|
-
return purry(_meanBy(true),
|
|
1165
|
+
function indexed(...args) {
|
|
1166
|
+
return purry(_meanBy(true), args);
|
|
1161
1167
|
}
|
|
1162
1168
|
meanBy2.indexed = indexed;
|
|
1163
1169
|
})(meanBy || (meanBy = {}));
|
|
@@ -1182,19 +1188,19 @@ function _minBy(indexed) {
|
|
|
1182
1188
|
return ret;
|
|
1183
1189
|
};
|
|
1184
1190
|
}
|
|
1185
|
-
function minBy() {
|
|
1186
|
-
return purry(_minBy(false),
|
|
1191
|
+
function minBy(...args) {
|
|
1192
|
+
return purry(_minBy(false), args);
|
|
1187
1193
|
}
|
|
1188
1194
|
((minBy2) => {
|
|
1189
|
-
function indexed() {
|
|
1190
|
-
return purry(_minBy(true),
|
|
1195
|
+
function indexed(...args) {
|
|
1196
|
+
return purry(_minBy(true), args);
|
|
1191
1197
|
}
|
|
1192
1198
|
minBy2.indexed = indexed;
|
|
1193
1199
|
})(minBy || (minBy = {}));
|
|
1194
1200
|
|
|
1195
1201
|
// src/array/partition.ts
|
|
1196
|
-
function partition() {
|
|
1197
|
-
return purry(_partition(false),
|
|
1202
|
+
function partition(...args) {
|
|
1203
|
+
return purry(_partition(false), args);
|
|
1198
1204
|
}
|
|
1199
1205
|
function _partition(indexed) {
|
|
1200
1206
|
return (array, fn) => {
|
|
@@ -1207,15 +1213,15 @@ function _partition(indexed) {
|
|
|
1207
1213
|
};
|
|
1208
1214
|
}
|
|
1209
1215
|
((partition2) => {
|
|
1210
|
-
function indexed() {
|
|
1211
|
-
return purry(_partition(true),
|
|
1216
|
+
function indexed(...args) {
|
|
1217
|
+
return purry(_partition(true), args);
|
|
1212
1218
|
}
|
|
1213
1219
|
partition2.indexed = indexed;
|
|
1214
1220
|
})(partition || (partition = {}));
|
|
1215
1221
|
|
|
1216
1222
|
// src/array/range.ts
|
|
1217
|
-
function range() {
|
|
1218
|
-
return purry(_range,
|
|
1223
|
+
function range(...args) {
|
|
1224
|
+
return purry(_range, args);
|
|
1219
1225
|
}
|
|
1220
1226
|
function _range(start, end) {
|
|
1221
1227
|
const ret = [];
|
|
@@ -1226,8 +1232,8 @@ function _range(start, end) {
|
|
|
1226
1232
|
}
|
|
1227
1233
|
|
|
1228
1234
|
// src/array/reduce.ts
|
|
1229
|
-
function reduce() {
|
|
1230
|
-
return purry(_reduce(false),
|
|
1235
|
+
function reduce(...args) {
|
|
1236
|
+
return purry(_reduce(false), args);
|
|
1231
1237
|
}
|
|
1232
1238
|
function _reduce(indexed) {
|
|
1233
1239
|
return (items, fn, initialValue) => {
|
|
@@ -1238,15 +1244,15 @@ function _reduce(indexed) {
|
|
|
1238
1244
|
};
|
|
1239
1245
|
}
|
|
1240
1246
|
((reduce2) => {
|
|
1241
|
-
function indexed() {
|
|
1242
|
-
return purry(_reduce(true),
|
|
1247
|
+
function indexed(...args) {
|
|
1248
|
+
return purry(_reduce(true), args);
|
|
1243
1249
|
}
|
|
1244
1250
|
reduce2.indexed = indexed;
|
|
1245
1251
|
})(reduce || (reduce = {}));
|
|
1246
1252
|
|
|
1247
1253
|
// src/array/reject.ts
|
|
1248
|
-
function reject() {
|
|
1249
|
-
return purry(_reject(false),
|
|
1254
|
+
function reject(...args) {
|
|
1255
|
+
return purry(_reject(false), args, reject.lazy);
|
|
1250
1256
|
}
|
|
1251
1257
|
function _reject(indexed) {
|
|
1252
1258
|
return (array, fn) => {
|
|
@@ -1276,8 +1282,8 @@ function _lazy6(indexed) {
|
|
|
1276
1282
|
};
|
|
1277
1283
|
}
|
|
1278
1284
|
((reject2) => {
|
|
1279
|
-
function indexed() {
|
|
1280
|
-
return purry(_reject(true),
|
|
1285
|
+
function indexed(...args) {
|
|
1286
|
+
return purry(_reject(true), args, reject2.lazyIndexed);
|
|
1281
1287
|
}
|
|
1282
1288
|
reject2.indexed = indexed;
|
|
1283
1289
|
reject2.lazy = _lazy6(false);
|
|
@@ -1285,8 +1291,8 @@ function _lazy6(indexed) {
|
|
|
1285
1291
|
})(reject || (reject = {}));
|
|
1286
1292
|
|
|
1287
1293
|
// src/array/reverse.ts
|
|
1288
|
-
function reverse() {
|
|
1289
|
-
return purry(_reverse,
|
|
1294
|
+
function reverse(...args) {
|
|
1295
|
+
return purry(_reverse, args);
|
|
1290
1296
|
}
|
|
1291
1297
|
function _reverse(array) {
|
|
1292
1298
|
return array.slice().reverse();
|
|
@@ -1322,8 +1328,8 @@ function sampleImplementation(data, sampleSize) {
|
|
|
1322
1328
|
}
|
|
1323
1329
|
|
|
1324
1330
|
// src/array/shuffle.ts
|
|
1325
|
-
function shuffle() {
|
|
1326
|
-
return purry(_shuffle,
|
|
1331
|
+
function shuffle(...args) {
|
|
1332
|
+
return purry(_shuffle, args);
|
|
1327
1333
|
}
|
|
1328
1334
|
function _shuffle(items) {
|
|
1329
1335
|
const result = items.slice();
|
|
@@ -1337,8 +1343,8 @@ function _shuffle(items) {
|
|
|
1337
1343
|
}
|
|
1338
1344
|
|
|
1339
1345
|
// src/array/sort.ts
|
|
1340
|
-
function sort() {
|
|
1341
|
-
return purry(_sort,
|
|
1346
|
+
function sort(...args) {
|
|
1347
|
+
return purry(_sort, args);
|
|
1342
1348
|
}
|
|
1343
1349
|
function _sort(items, cmp) {
|
|
1344
1350
|
const ret = [...items];
|
|
@@ -1356,17 +1362,7 @@ var COMPARATOR = {
|
|
|
1356
1362
|
desc: (x, y) => x < y
|
|
1357
1363
|
};
|
|
1358
1364
|
function sortBy(arrayOrSortRule, ...sortRules) {
|
|
1359
|
-
const args = isSortRule(arrayOrSortRule) ?
|
|
1360
|
-
// *data-last invocation*: put all sort rules into a single array to be
|
|
1361
|
-
// passed as the first param.
|
|
1362
|
-
[[arrayOrSortRule, ...sortRules]]
|
|
1363
|
-
) : (
|
|
1364
|
-
// *data-first invocation*: put the arrayOrSort (which is array now) as
|
|
1365
|
-
// the first param, and all the sorts (as an array) into the second param.
|
|
1366
|
-
// `purry` would pick the right "flavour" based on the length of the
|
|
1367
|
-
// params tuple.
|
|
1368
|
-
[arrayOrSortRule, sortRules]
|
|
1369
|
-
);
|
|
1365
|
+
const args = isSortRule(arrayOrSortRule) ? [[arrayOrSortRule, ...sortRules]] : [arrayOrSortRule, sortRules];
|
|
1370
1366
|
return purry(_sortBy, args);
|
|
1371
1367
|
}
|
|
1372
1368
|
function isSortRule(x) {
|
|
@@ -1404,8 +1400,8 @@ function comparer(primaryRule, secondaryRule, ...otherRules) {
|
|
|
1404
1400
|
})(sortBy || (sortBy = {}));
|
|
1405
1401
|
|
|
1406
1402
|
// src/array/split-at.ts
|
|
1407
|
-
function splitAt() {
|
|
1408
|
-
return purry(_splitAt,
|
|
1403
|
+
function splitAt(...args) {
|
|
1404
|
+
return purry(_splitAt, args);
|
|
1409
1405
|
}
|
|
1410
1406
|
function _splitAt(array, index) {
|
|
1411
1407
|
const copy = [...array];
|
|
@@ -1414,8 +1410,8 @@ function _splitAt(array, index) {
|
|
|
1414
1410
|
}
|
|
1415
1411
|
|
|
1416
1412
|
// src/array/split-when.ts
|
|
1417
|
-
function splitWhen() {
|
|
1418
|
-
return purry(_splitWhen,
|
|
1413
|
+
function splitWhen(...args) {
|
|
1414
|
+
return purry(_splitWhen, args);
|
|
1419
1415
|
}
|
|
1420
1416
|
function _splitWhen(array, fn) {
|
|
1421
1417
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -1437,12 +1433,12 @@ function _sumBy(indexed) {
|
|
|
1437
1433
|
return sum;
|
|
1438
1434
|
};
|
|
1439
1435
|
}
|
|
1440
|
-
function sumBy() {
|
|
1441
|
-
return purry(_sumBy(false),
|
|
1436
|
+
function sumBy(...args) {
|
|
1437
|
+
return purry(_sumBy(false), args);
|
|
1442
1438
|
}
|
|
1443
1439
|
((sumBy2) => {
|
|
1444
|
-
function indexed() {
|
|
1445
|
-
return purry(_sumBy(true),
|
|
1440
|
+
function indexed(...args) {
|
|
1441
|
+
return purry(_sumBy(true), args);
|
|
1446
1442
|
}
|
|
1447
1443
|
sumBy2.indexed = indexed;
|
|
1448
1444
|
})(sumBy || (sumBy = {}));
|
|
@@ -1477,8 +1473,8 @@ function _swapString(item, index1, index2) {
|
|
|
1477
1473
|
}
|
|
1478
1474
|
|
|
1479
1475
|
// src/array/take.ts
|
|
1480
|
-
function take() {
|
|
1481
|
-
return purry(_take,
|
|
1476
|
+
function take(...args) {
|
|
1477
|
+
return purry(_take, args, take.lazy);
|
|
1482
1478
|
}
|
|
1483
1479
|
function _take(array, n) {
|
|
1484
1480
|
return _reduceLazy(array, take.lazy(n));
|
|
@@ -1511,8 +1507,8 @@ function _take(array, n) {
|
|
|
1511
1507
|
})(take || (take = {}));
|
|
1512
1508
|
|
|
1513
1509
|
// src/array/take-while.ts
|
|
1514
|
-
function takeWhile() {
|
|
1515
|
-
return purry(_takeWhile,
|
|
1510
|
+
function takeWhile(...args) {
|
|
1511
|
+
return purry(_takeWhile, args);
|
|
1516
1512
|
}
|
|
1517
1513
|
function _takeWhile(array, fn) {
|
|
1518
1514
|
const ret = [];
|
|
@@ -1526,8 +1522,8 @@ function _takeWhile(array, fn) {
|
|
|
1526
1522
|
}
|
|
1527
1523
|
|
|
1528
1524
|
// src/array/uniq.ts
|
|
1529
|
-
function uniq() {
|
|
1530
|
-
return purry(_uniq,
|
|
1525
|
+
function uniq(...args) {
|
|
1526
|
+
return purry(_uniq, args, uniq.lazy);
|
|
1531
1527
|
}
|
|
1532
1528
|
function _uniq(array) {
|
|
1533
1529
|
return _reduceLazy(array, uniq.lazy());
|
|
@@ -1554,8 +1550,8 @@ function _uniq(array) {
|
|
|
1554
1550
|
})(uniq || (uniq = {}));
|
|
1555
1551
|
|
|
1556
1552
|
// src/array/uniq-by.ts
|
|
1557
|
-
function uniqBy() {
|
|
1558
|
-
return purry(_uniqBy,
|
|
1553
|
+
function uniqBy(...args) {
|
|
1554
|
+
return purry(_uniqBy, args, lazyUniqBy);
|
|
1559
1555
|
}
|
|
1560
1556
|
function _uniqBy(array, transformer) {
|
|
1561
1557
|
return _reduceLazy(array, lazyUniqBy(transformer));
|
|
@@ -1580,8 +1576,8 @@ function lazyUniqBy(transformer) {
|
|
|
1580
1576
|
}
|
|
1581
1577
|
|
|
1582
1578
|
// src/array/uniq-with.ts
|
|
1583
|
-
function uniqWith() {
|
|
1584
|
-
return purry(_uniqWith,
|
|
1579
|
+
function uniqWith(...args) {
|
|
1580
|
+
return purry(_uniqWith, args, uniqWith.lazy);
|
|
1585
1581
|
}
|
|
1586
1582
|
function _uniqWith(array, isEquals) {
|
|
1587
1583
|
const lazy = uniqWith.lazy(isEquals);
|
|
@@ -1607,8 +1603,8 @@ function _lazy7(isEquals) {
|
|
|
1607
1603
|
})(uniqWith || (uniqWith = {}));
|
|
1608
1604
|
|
|
1609
1605
|
// src/array/zip.ts
|
|
1610
|
-
function zip() {
|
|
1611
|
-
return purry(_zip,
|
|
1606
|
+
function zip(...args) {
|
|
1607
|
+
return purry(_zip, args);
|
|
1612
1608
|
}
|
|
1613
1609
|
function _zip(first2, second) {
|
|
1614
1610
|
const resultLength = first2.length > second.length ? second.length : first2.length;
|
|
@@ -1620,8 +1616,8 @@ function _zip(first2, second) {
|
|
|
1620
1616
|
}
|
|
1621
1617
|
|
|
1622
1618
|
// src/array/zip-obj.ts
|
|
1623
|
-
function zipObj() {
|
|
1624
|
-
return purry(_zipObj,
|
|
1619
|
+
function zipObj(...args) {
|
|
1620
|
+
return purry(_zipObj, args);
|
|
1625
1621
|
}
|
|
1626
1622
|
function _zipObj(first2, second) {
|
|
1627
1623
|
const resultLength = first2.length > second.length ? second.length : first2.length;
|
|
@@ -1633,8 +1629,7 @@ function _zipObj(first2, second) {
|
|
|
1633
1629
|
}
|
|
1634
1630
|
|
|
1635
1631
|
// src/array/zip-with.ts
|
|
1636
|
-
function zipWith() {
|
|
1637
|
-
const args = Array.from(arguments);
|
|
1632
|
+
function zipWith(...args) {
|
|
1638
1633
|
if (typeof args[0] === "function" && args.length === 1) {
|
|
1639
1634
|
return function(f, s) {
|
|
1640
1635
|
return _zipWith(f, s, args[0]);
|
|
@@ -1658,51 +1653,9 @@ function _zipWith(first2, second, fn) {
|
|
|
1658
1653
|
return result;
|
|
1659
1654
|
}
|
|
1660
1655
|
|
|
1661
|
-
// src/helpers/index.ts
|
|
1662
|
-
function convertToUnit(str, unit = "px") {
|
|
1663
|
-
if (isNil(str) || str === "") {
|
|
1664
|
-
return void 0;
|
|
1665
|
-
} else if (Number.isNaN(+str)) {
|
|
1666
|
-
return String(str);
|
|
1667
|
-
} else if (!Number.isFinite(+str)) {
|
|
1668
|
-
return void 0;
|
|
1669
|
-
} else {
|
|
1670
|
-
return `${Number(str)}${unit}`;
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
function increaseWithUnit({ target, delta }) {
|
|
1674
|
-
if (isNumber(target)) {
|
|
1675
|
-
return target + delta;
|
|
1676
|
-
}
|
|
1677
|
-
const value = target.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
|
|
1678
|
-
const unit = target.slice(value.length);
|
|
1679
|
-
const result = Number.parseFloat(value) + delta;
|
|
1680
|
-
if (Number.isNaN(result)) {
|
|
1681
|
-
return target;
|
|
1682
|
-
}
|
|
1683
|
-
return result + unit;
|
|
1684
|
-
}
|
|
1685
|
-
function humanReadableFileSize(bytes, base = 1e3) {
|
|
1686
|
-
if (bytes < base) {
|
|
1687
|
-
return `${bytes} B`;
|
|
1688
|
-
}
|
|
1689
|
-
const prefix = base === 1024 ? ["Ki", "Mi", "Gi"] : ["k", "M", "G"];
|
|
1690
|
-
let unit = -1;
|
|
1691
|
-
while (Math.abs(bytes) >= base && unit < prefix.length - 1) {
|
|
1692
|
-
bytes /= base;
|
|
1693
|
-
++unit;
|
|
1694
|
-
}
|
|
1695
|
-
return `${bytes.toFixed(1)} ${prefix[unit]}B`;
|
|
1696
|
-
}
|
|
1697
|
-
function sleep(timeout) {
|
|
1698
|
-
return new Promise((resolve) => {
|
|
1699
|
-
setTimeout(resolve, timeout);
|
|
1700
|
-
});
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
1656
|
// src/number/clamp.ts
|
|
1704
|
-
function clamp() {
|
|
1705
|
-
return purry(_clamp,
|
|
1657
|
+
function clamp(...args) {
|
|
1658
|
+
return purry(_clamp, args);
|
|
1706
1659
|
}
|
|
1707
1660
|
function _clamp(value, limits) {
|
|
1708
1661
|
if (limits.min != null && limits.min > value) {
|
|
@@ -1727,7 +1680,13 @@ function _addProp(obj, prop2, value) {
|
|
|
1727
1680
|
|
|
1728
1681
|
// src/type/type.ts
|
|
1729
1682
|
function type(val) {
|
|
1730
|
-
|
|
1683
|
+
if (val === null) {
|
|
1684
|
+
return "Null";
|
|
1685
|
+
}
|
|
1686
|
+
if (val === void 0) {
|
|
1687
|
+
return "Undefined";
|
|
1688
|
+
}
|
|
1689
|
+
return Object.prototype.toString.call(val).slice(8, -1);
|
|
1731
1690
|
}
|
|
1732
1691
|
|
|
1733
1692
|
// src/object/clone.ts
|
|
@@ -1774,8 +1733,8 @@ function clone(value) {
|
|
|
1774
1733
|
// src/object/equals.ts
|
|
1775
1734
|
var isArray2 = Array.isArray;
|
|
1776
1735
|
var keyList = Object.keys;
|
|
1777
|
-
function equals() {
|
|
1778
|
-
return purry(_equals,
|
|
1736
|
+
function equals(...args) {
|
|
1737
|
+
return purry(_equals, args);
|
|
1779
1738
|
}
|
|
1780
1739
|
function _equals(a, b) {
|
|
1781
1740
|
if (a === b) {
|
|
@@ -1840,8 +1799,8 @@ function _equals(a, b) {
|
|
|
1840
1799
|
}
|
|
1841
1800
|
|
|
1842
1801
|
// src/object/for-each-obj.ts
|
|
1843
|
-
function forEachObj() {
|
|
1844
|
-
return purry(_forEachObj(false),
|
|
1802
|
+
function forEachObj(...args) {
|
|
1803
|
+
return purry(_forEachObj(false), args);
|
|
1845
1804
|
}
|
|
1846
1805
|
function _forEachObj(indexed) {
|
|
1847
1806
|
return (object, fn) => {
|
|
@@ -1859,8 +1818,8 @@ function _forEachObj(indexed) {
|
|
|
1859
1818
|
};
|
|
1860
1819
|
}
|
|
1861
1820
|
((forEachObj2) => {
|
|
1862
|
-
function indexed() {
|
|
1863
|
-
return purry(_forEachObj(true),
|
|
1821
|
+
function indexed(...args) {
|
|
1822
|
+
return purry(_forEachObj(true), args);
|
|
1864
1823
|
}
|
|
1865
1824
|
forEachObj2.indexed = indexed;
|
|
1866
1825
|
})(forEachObj || (forEachObj = {}));
|
|
@@ -1878,8 +1837,8 @@ function fromPairs(entries) {
|
|
|
1878
1837
|
})(fromPairs || (fromPairs = {}));
|
|
1879
1838
|
|
|
1880
1839
|
// src/object/invert.ts
|
|
1881
|
-
function invert() {
|
|
1882
|
-
return purry(_invert,
|
|
1840
|
+
function invert(...args) {
|
|
1841
|
+
return purry(_invert, args);
|
|
1883
1842
|
}
|
|
1884
1843
|
function _invert(object) {
|
|
1885
1844
|
const result = {};
|
|
@@ -1926,16 +1885,16 @@ function _mapValues(obj, fn) {
|
|
|
1926
1885
|
}
|
|
1927
1886
|
|
|
1928
1887
|
// src/object/merge.ts
|
|
1929
|
-
function merge() {
|
|
1930
|
-
return purry(_merge,
|
|
1888
|
+
function merge(...args) {
|
|
1889
|
+
return purry(_merge, args);
|
|
1931
1890
|
}
|
|
1932
1891
|
function _merge(a, b) {
|
|
1933
1892
|
return Object.assign({}, a, b);
|
|
1934
1893
|
}
|
|
1935
1894
|
|
|
1936
1895
|
// src/object/omit.ts
|
|
1937
|
-
function omit() {
|
|
1938
|
-
return purry(_omit,
|
|
1896
|
+
function omit(...args) {
|
|
1897
|
+
return purry(_omit, args);
|
|
1939
1898
|
}
|
|
1940
1899
|
function _omit(data, propNames) {
|
|
1941
1900
|
if (propNames.length === 0) {
|
|
@@ -1944,7 +1903,6 @@ function _omit(data, propNames) {
|
|
|
1944
1903
|
if (propNames.length === 1) {
|
|
1945
1904
|
const [propName] = propNames;
|
|
1946
1905
|
const {
|
|
1947
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- use destructuring to remove a single key, letting JS optimize here...
|
|
1948
1906
|
[propName]: omitted,
|
|
1949
1907
|
...remaining
|
|
1950
1908
|
} = data;
|
|
@@ -1960,8 +1918,8 @@ function _omit(data, propNames) {
|
|
|
1960
1918
|
}
|
|
1961
1919
|
|
|
1962
1920
|
// src/object/omit-by.ts
|
|
1963
|
-
function omitBy() {
|
|
1964
|
-
return purry(_omitBy,
|
|
1921
|
+
function omitBy(...args) {
|
|
1922
|
+
return purry(_omitBy, args);
|
|
1965
1923
|
}
|
|
1966
1924
|
function _omitBy(object, fn) {
|
|
1967
1925
|
return Object.keys(object).reduce((acc, key) => {
|
|
@@ -1973,8 +1931,8 @@ function _omitBy(object, fn) {
|
|
|
1973
1931
|
}
|
|
1974
1932
|
|
|
1975
1933
|
// src/object/path-or.ts
|
|
1976
|
-
function pathOr() {
|
|
1977
|
-
return purry(_pathOr,
|
|
1934
|
+
function pathOr(...args) {
|
|
1935
|
+
return purry(_pathOr, args);
|
|
1978
1936
|
}
|
|
1979
1937
|
function _pathOr(object, path, defaultValue) {
|
|
1980
1938
|
let current = object;
|
|
@@ -1988,8 +1946,8 @@ function _pathOr(object, path, defaultValue) {
|
|
|
1988
1946
|
}
|
|
1989
1947
|
|
|
1990
1948
|
// src/object/pick.ts
|
|
1991
|
-
function pick() {
|
|
1992
|
-
return purry(_pick,
|
|
1949
|
+
function pick(...args) {
|
|
1950
|
+
return purry(_pick, args);
|
|
1993
1951
|
}
|
|
1994
1952
|
function _pick(object, names) {
|
|
1995
1953
|
if (object == null) {
|
|
@@ -2004,8 +1962,8 @@ function _pick(object, names) {
|
|
|
2004
1962
|
}
|
|
2005
1963
|
|
|
2006
1964
|
// src/object/pick-by.ts
|
|
2007
|
-
function pickBy() {
|
|
2008
|
-
return purry(_pickBy,
|
|
1965
|
+
function pickBy(...args) {
|
|
1966
|
+
return purry(_pickBy, args);
|
|
2009
1967
|
}
|
|
2010
1968
|
function _pickBy(object, fn) {
|
|
2011
1969
|
if (object == null) {
|
|
@@ -2025,8 +1983,8 @@ function prop(propName) {
|
|
|
2025
1983
|
}
|
|
2026
1984
|
|
|
2027
1985
|
// src/object/set.ts
|
|
2028
|
-
function set() {
|
|
2029
|
-
return purry(_set,
|
|
1986
|
+
function set(...args) {
|
|
1987
|
+
return purry(_set, args);
|
|
2030
1988
|
}
|
|
2031
1989
|
function _set(obj, prop2, value) {
|
|
2032
1990
|
return {
|
|
@@ -2036,8 +1994,8 @@ function _set(obj, prop2, value) {
|
|
|
2036
1994
|
}
|
|
2037
1995
|
|
|
2038
1996
|
// src/object/set-path.ts
|
|
2039
|
-
function setPath() {
|
|
2040
|
-
return purry(_setPath,
|
|
1997
|
+
function setPath(...args) {
|
|
1998
|
+
return purry(_setPath, args);
|
|
2041
1999
|
}
|
|
2042
2000
|
function _setPath(object, path, defaultValue) {
|
|
2043
2001
|
if (path.length === 0) {
|
|
@@ -2058,8 +2016,8 @@ function _setPath(object, path, defaultValue) {
|
|
|
2058
2016
|
}
|
|
2059
2017
|
|
|
2060
2018
|
// src/object/swap-props.ts
|
|
2061
|
-
function swapProps() {
|
|
2062
|
-
return purry(_swapProps,
|
|
2019
|
+
function swapProps(...args) {
|
|
2020
|
+
return purry(_swapProps, args);
|
|
2063
2021
|
}
|
|
2064
2022
|
function _swapProps(obj, key1, key2) {
|
|
2065
2023
|
const { [key1]: value1, [key2]: value2 } = obj;
|
|
@@ -2154,6 +2112,20 @@ function toSnakeCase(string_) {
|
|
|
2154
2112
|
return toKebabCase(string_ || "", "_");
|
|
2155
2113
|
}
|
|
2156
2114
|
|
|
2115
|
+
// src/string/human-readable-file-size.ts
|
|
2116
|
+
function humanReadableFileSize(bytes, base = 1e3) {
|
|
2117
|
+
if (bytes < base) {
|
|
2118
|
+
return `${bytes} B`;
|
|
2119
|
+
}
|
|
2120
|
+
const prefix = base === 1024 ? ["Ki", "Mi", "Gi"] : ["k", "M", "G"];
|
|
2121
|
+
let unit = -1;
|
|
2122
|
+
while (Math.abs(bytes) >= base && unit < prefix.length - 1) {
|
|
2123
|
+
bytes /= base;
|
|
2124
|
+
++unit;
|
|
2125
|
+
}
|
|
2126
|
+
return `${bytes.toFixed(1)} ${prefix[unit]}B`;
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2157
2129
|
// src/string/random-string.ts
|
|
2158
2130
|
function randomString(length2) {
|
|
2159
2131
|
const characterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
@@ -2161,6 +2133,11 @@ function randomString(length2) {
|
|
|
2161
2133
|
return range(0, length2).reduce((text) => text + randomChar(), "");
|
|
2162
2134
|
}
|
|
2163
2135
|
|
|
2136
|
+
// src/string/slugify.ts
|
|
2137
|
+
function slugify(str) {
|
|
2138
|
+
return str.normalize("NFD").replace(/[\u0300-\u036F]/g, "").toLowerCase().replace(/[^a-z0-9]/g, " ").trim().replace(/\s+/g, "-");
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2164
2141
|
// src/string/string-to-path.ts
|
|
2165
2142
|
function stringToPath(path) {
|
|
2166
2143
|
return _stringToPath(path);
|
|
@@ -2191,7 +2168,6 @@ var isBrowser = typeof window !== "undefined";
|
|
|
2191
2168
|
clone,
|
|
2192
2169
|
compact,
|
|
2193
2170
|
concat,
|
|
2194
|
-
convertToUnit,
|
|
2195
2171
|
countBy,
|
|
2196
2172
|
createPipe,
|
|
2197
2173
|
difference,
|
|
@@ -2215,7 +2191,6 @@ var isBrowser = typeof window !== "undefined";
|
|
|
2215
2191
|
groupBy,
|
|
2216
2192
|
humanReadableFileSize,
|
|
2217
2193
|
identity,
|
|
2218
|
-
increaseWithUnit,
|
|
2219
2194
|
indexBy,
|
|
2220
2195
|
intersection,
|
|
2221
2196
|
intersectionWith,
|
|
@@ -2271,6 +2246,7 @@ var isBrowser = typeof window !== "undefined";
|
|
|
2271
2246
|
setPath,
|
|
2272
2247
|
shuffle,
|
|
2273
2248
|
sleep,
|
|
2249
|
+
slugify,
|
|
2274
2250
|
sort,
|
|
2275
2251
|
sortBy,
|
|
2276
2252
|
splitAt,
|