@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.js
CHANGED
|
@@ -172,25 +172,32 @@ function purry(fn, args, lazy) {
|
|
|
172
172
|
throw new Error("Wrong number of arguments");
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
// src/function/sleep.ts
|
|
176
|
+
function sleep(timeout) {
|
|
177
|
+
return new Promise((resolve) => {
|
|
178
|
+
setTimeout(resolve, timeout);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
175
182
|
// src/array/all-pass.ts
|
|
176
|
-
function allPass() {
|
|
177
|
-
return purry(_allPass,
|
|
183
|
+
function allPass(...args) {
|
|
184
|
+
return purry(_allPass, args);
|
|
178
185
|
}
|
|
179
186
|
function _allPass(data, fns) {
|
|
180
187
|
return fns.every((fn) => fn(data));
|
|
181
188
|
}
|
|
182
189
|
|
|
183
190
|
// src/array/any-pass.ts
|
|
184
|
-
function anyPass() {
|
|
185
|
-
return purry(_anyPass,
|
|
191
|
+
function anyPass(...args) {
|
|
192
|
+
return purry(_anyPass, args);
|
|
186
193
|
}
|
|
187
194
|
function _anyPass(data, fns) {
|
|
188
195
|
return fns.some((fn) => fn(data));
|
|
189
196
|
}
|
|
190
197
|
|
|
191
198
|
// src/array/chunk.ts
|
|
192
|
-
function chunk() {
|
|
193
|
-
return purry(_chunk,
|
|
199
|
+
function chunk(...args) {
|
|
200
|
+
return purry(_chunk, args);
|
|
194
201
|
}
|
|
195
202
|
function _chunk(array, size) {
|
|
196
203
|
const ret = Array.from({
|
|
@@ -305,8 +312,8 @@ function compact(items) {
|
|
|
305
312
|
}
|
|
306
313
|
|
|
307
314
|
// src/array/concat.ts
|
|
308
|
-
function concat() {
|
|
309
|
-
return purry(_concat,
|
|
315
|
+
function concat(...args) {
|
|
316
|
+
return purry(_concat, args);
|
|
310
317
|
}
|
|
311
318
|
function _concat(arr1, arr2) {
|
|
312
319
|
return arr1.concat(arr2);
|
|
@@ -321,12 +328,12 @@ function _countBy(indexed) {
|
|
|
321
328
|
}, 0);
|
|
322
329
|
};
|
|
323
330
|
}
|
|
324
|
-
function countBy() {
|
|
325
|
-
return purry(_countBy(false),
|
|
331
|
+
function countBy(...args) {
|
|
332
|
+
return purry(_countBy(false), args);
|
|
326
333
|
}
|
|
327
334
|
((countBy2) => {
|
|
328
|
-
function indexed() {
|
|
329
|
-
return purry(_countBy(true),
|
|
335
|
+
function indexed(...args) {
|
|
336
|
+
return purry(_countBy(true), args);
|
|
330
337
|
}
|
|
331
338
|
countBy2.indexed = indexed;
|
|
332
339
|
})(countBy || (countBy = {}));
|
|
@@ -347,8 +354,8 @@ function _reduceLazy(array, lazy, indexed) {
|
|
|
347
354
|
}
|
|
348
355
|
|
|
349
356
|
// src/array/difference-with.ts
|
|
350
|
-
function differenceWith() {
|
|
351
|
-
return purry(_differenceWith,
|
|
357
|
+
function differenceWith(...args) {
|
|
358
|
+
return purry(_differenceWith, args, differenceWith.lazy);
|
|
352
359
|
}
|
|
353
360
|
function _differenceWith(array, other, isEquals) {
|
|
354
361
|
const lazy = differenceWith.lazy(other, isEquals);
|
|
@@ -374,8 +381,8 @@ function _differenceWith(array, other, isEquals) {
|
|
|
374
381
|
})(differenceWith || (differenceWith = {}));
|
|
375
382
|
|
|
376
383
|
// src/array/difference.ts
|
|
377
|
-
function difference() {
|
|
378
|
-
return purry(_difference,
|
|
384
|
+
function difference(...args) {
|
|
385
|
+
return purry(_difference, args, difference.lazy);
|
|
379
386
|
}
|
|
380
387
|
function _difference(array, other) {
|
|
381
388
|
const lazy = difference.lazy(other);
|
|
@@ -402,8 +409,8 @@ function _difference(array, other) {
|
|
|
402
409
|
})(difference || (difference = {}));
|
|
403
410
|
|
|
404
411
|
// src/array/drop-last.ts
|
|
405
|
-
function dropLast() {
|
|
406
|
-
return purry(_dropLast,
|
|
412
|
+
function dropLast(...args) {
|
|
413
|
+
return purry(_dropLast, args);
|
|
407
414
|
}
|
|
408
415
|
function _dropLast(array, n) {
|
|
409
416
|
const copy = [...array];
|
|
@@ -414,8 +421,8 @@ function _dropLast(array, n) {
|
|
|
414
421
|
}
|
|
415
422
|
|
|
416
423
|
// src/array/drop.ts
|
|
417
|
-
function drop() {
|
|
418
|
-
return purry(_drop,
|
|
424
|
+
function drop(...args) {
|
|
425
|
+
return purry(_drop, args, drop.lazy);
|
|
419
426
|
}
|
|
420
427
|
function _drop(array, n) {
|
|
421
428
|
return _reduceLazy(array, drop.lazy(n));
|
|
@@ -448,8 +455,8 @@ function toLazyIndexed(fn) {
|
|
|
448
455
|
}
|
|
449
456
|
|
|
450
457
|
// src/array/filter.ts
|
|
451
|
-
function filter() {
|
|
452
|
-
return purry(_filter(false),
|
|
458
|
+
function filter(...args) {
|
|
459
|
+
return purry(_filter(false), args, filter.lazy);
|
|
453
460
|
}
|
|
454
461
|
function _filter(indexed) {
|
|
455
462
|
return (array, fn) => {
|
|
@@ -479,8 +486,8 @@ function _lazy(indexed) {
|
|
|
479
486
|
};
|
|
480
487
|
}
|
|
481
488
|
((filter2) => {
|
|
482
|
-
function indexed() {
|
|
483
|
-
return purry(_filter(true),
|
|
489
|
+
function indexed(...args) {
|
|
490
|
+
return purry(_filter(true), args, filter2.lazyIndexed);
|
|
484
491
|
}
|
|
485
492
|
filter2.indexed = indexed;
|
|
486
493
|
filter2.lazy = _lazy(false);
|
|
@@ -494,8 +501,8 @@ function toSingle(fn) {
|
|
|
494
501
|
}
|
|
495
502
|
|
|
496
503
|
// src/array/find-index.ts
|
|
497
|
-
function findIndex() {
|
|
498
|
-
return purry(_findIndex(false),
|
|
504
|
+
function findIndex(...args) {
|
|
505
|
+
return purry(_findIndex(false), args, findIndex.lazy);
|
|
499
506
|
}
|
|
500
507
|
function _findIndex(indexed) {
|
|
501
508
|
return (array, fn) => {
|
|
@@ -526,8 +533,8 @@ function _lazy2(indexed) {
|
|
|
526
533
|
};
|
|
527
534
|
}
|
|
528
535
|
((findIndex2) => {
|
|
529
|
-
function indexed() {
|
|
530
|
-
return purry(_findIndex(true),
|
|
536
|
+
function indexed(...args) {
|
|
537
|
+
return purry(_findIndex(true), args, findIndex2.lazyIndexed);
|
|
531
538
|
}
|
|
532
539
|
findIndex2.indexed = indexed;
|
|
533
540
|
findIndex2.lazy = toSingle(_lazy2(false));
|
|
@@ -535,8 +542,8 @@ function _lazy2(indexed) {
|
|
|
535
542
|
})(findIndex || (findIndex = {}));
|
|
536
543
|
|
|
537
544
|
// src/array/find-last-index.ts
|
|
538
|
-
function findLastIndex() {
|
|
539
|
-
return purry(_findLastIndex(false),
|
|
545
|
+
function findLastIndex(...args) {
|
|
546
|
+
return purry(_findLastIndex(false), args);
|
|
540
547
|
}
|
|
541
548
|
function _findLastIndex(indexed) {
|
|
542
549
|
return (array, fn) => {
|
|
@@ -549,15 +556,15 @@ function _findLastIndex(indexed) {
|
|
|
549
556
|
};
|
|
550
557
|
}
|
|
551
558
|
((findLastIndex2) => {
|
|
552
|
-
function indexed() {
|
|
553
|
-
return purry(_findLastIndex(true),
|
|
559
|
+
function indexed(...args) {
|
|
560
|
+
return purry(_findLastIndex(true), args);
|
|
554
561
|
}
|
|
555
562
|
findLastIndex2.indexed = indexed;
|
|
556
563
|
})(findLastIndex || (findLastIndex = {}));
|
|
557
564
|
|
|
558
565
|
// src/array/find-last.ts
|
|
559
|
-
function findLast() {
|
|
560
|
-
return purry(_findLast(false),
|
|
566
|
+
function findLast(...args) {
|
|
567
|
+
return purry(_findLast(false), args);
|
|
561
568
|
}
|
|
562
569
|
function _findLast(indexed) {
|
|
563
570
|
return (array, fn) => {
|
|
@@ -569,15 +576,15 @@ function _findLast(indexed) {
|
|
|
569
576
|
};
|
|
570
577
|
}
|
|
571
578
|
((findLast2) => {
|
|
572
|
-
function indexed() {
|
|
573
|
-
return purry(_findLast(true),
|
|
579
|
+
function indexed(...args) {
|
|
580
|
+
return purry(_findLast(true), args);
|
|
574
581
|
}
|
|
575
582
|
findLast2.indexed = indexed;
|
|
576
583
|
})(findLast || (findLast = {}));
|
|
577
584
|
|
|
578
585
|
// src/array/find.ts
|
|
579
|
-
function find() {
|
|
580
|
-
return purry(_find(false),
|
|
586
|
+
function find(...args) {
|
|
587
|
+
return purry(_find(false), args, find.lazy);
|
|
581
588
|
}
|
|
582
589
|
function _find(indexed) {
|
|
583
590
|
return (array, fn) => {
|
|
@@ -600,8 +607,8 @@ function _lazy3(indexed) {
|
|
|
600
607
|
};
|
|
601
608
|
}
|
|
602
609
|
((find2) => {
|
|
603
|
-
function indexed() {
|
|
604
|
-
return purry(_find(true),
|
|
610
|
+
function indexed(...args) {
|
|
611
|
+
return purry(_find(true), args, find2.lazyIndexed);
|
|
605
612
|
}
|
|
606
613
|
find2.indexed = indexed;
|
|
607
614
|
find2.lazy = toSingle(_lazy3(false));
|
|
@@ -609,8 +616,8 @@ function _lazy3(indexed) {
|
|
|
609
616
|
})(find || (find = {}));
|
|
610
617
|
|
|
611
618
|
// src/array/first.ts
|
|
612
|
-
function first() {
|
|
613
|
-
return purry(_first,
|
|
619
|
+
function first(...args) {
|
|
620
|
+
return purry(_first, args, first.lazy);
|
|
614
621
|
}
|
|
615
622
|
function _first([first2]) {
|
|
616
623
|
return first2;
|
|
@@ -632,8 +639,8 @@ function _first([first2]) {
|
|
|
632
639
|
})(first || (first = {}));
|
|
633
640
|
|
|
634
641
|
// src/array/flat-map-to-obj.ts
|
|
635
|
-
function flatMapToObj() {
|
|
636
|
-
return purry(_flatMapToObj(false),
|
|
642
|
+
function flatMapToObj(...args) {
|
|
643
|
+
return purry(_flatMapToObj(false), args);
|
|
637
644
|
}
|
|
638
645
|
function _flatMapToObj(indexed) {
|
|
639
646
|
return (array, fn) => {
|
|
@@ -647,15 +654,15 @@ function _flatMapToObj(indexed) {
|
|
|
647
654
|
};
|
|
648
655
|
}
|
|
649
656
|
((flatMapToObj2) => {
|
|
650
|
-
function indexed() {
|
|
651
|
-
return purry(_flatMapToObj(true),
|
|
657
|
+
function indexed(...args) {
|
|
658
|
+
return purry(_flatMapToObj(true), args);
|
|
652
659
|
}
|
|
653
660
|
flatMapToObj2.indexed = indexed;
|
|
654
661
|
})(flatMapToObj || (flatMapToObj = {}));
|
|
655
662
|
|
|
656
663
|
// src/array/flatten.ts
|
|
657
|
-
function flatten() {
|
|
658
|
-
return purry(_flatten,
|
|
664
|
+
function flatten(...args) {
|
|
665
|
+
return purry(_flatten, args, flatten.lazy);
|
|
659
666
|
}
|
|
660
667
|
function _flatten(items) {
|
|
661
668
|
return _reduceLazy(items, flatten.lazy());
|
|
@@ -682,8 +689,8 @@ function _flatten(items) {
|
|
|
682
689
|
})(flatten || (flatten = {}));
|
|
683
690
|
|
|
684
691
|
// src/array/flat-map.ts
|
|
685
|
-
function flatMap() {
|
|
686
|
-
return purry(_flatMap,
|
|
692
|
+
function flatMap(...args) {
|
|
693
|
+
return purry(_flatMap, args, flatMap.lazy);
|
|
687
694
|
}
|
|
688
695
|
function _flatMap(array, fn) {
|
|
689
696
|
return flatten(array.map((item) => fn(item)));
|
|
@@ -711,8 +718,8 @@ function _flatMap(array, fn) {
|
|
|
711
718
|
})(flatMap || (flatMap = {}));
|
|
712
719
|
|
|
713
720
|
// src/array/flatten-deep.ts
|
|
714
|
-
function flattenDeep() {
|
|
715
|
-
return purry(_flattenDeep,
|
|
721
|
+
function flattenDeep(...args) {
|
|
722
|
+
return purry(_flattenDeep, args, flattenDeep.lazy);
|
|
716
723
|
}
|
|
717
724
|
function _flattenDeep(items) {
|
|
718
725
|
return _reduceLazy(items, flattenDeep.lazy());
|
|
@@ -754,8 +761,8 @@ function _flattenDeepValue(value) {
|
|
|
754
761
|
})(flattenDeep || (flattenDeep = {}));
|
|
755
762
|
|
|
756
763
|
// src/array/for-each.ts
|
|
757
|
-
function forEach() {
|
|
758
|
-
return purry(_forEach(false),
|
|
764
|
+
function forEach(...args) {
|
|
765
|
+
return purry(_forEach(false), args, forEach.lazy);
|
|
759
766
|
}
|
|
760
767
|
function _forEach(indexed) {
|
|
761
768
|
return (array, fn) => {
|
|
@@ -783,8 +790,8 @@ function _lazy4(indexed) {
|
|
|
783
790
|
};
|
|
784
791
|
}
|
|
785
792
|
((forEach2) => {
|
|
786
|
-
function indexed() {
|
|
787
|
-
return purry(_forEach(true),
|
|
793
|
+
function indexed(...args) {
|
|
794
|
+
return purry(_forEach(true), args, forEach2.lazyIndexed);
|
|
788
795
|
}
|
|
789
796
|
forEach2.indexed = indexed;
|
|
790
797
|
forEach2.lazy = _lazy4(false);
|
|
@@ -792,8 +799,8 @@ function _lazy4(indexed) {
|
|
|
792
799
|
})(forEach || (forEach = {}));
|
|
793
800
|
|
|
794
801
|
// src/array/group-by.ts
|
|
795
|
-
function groupBy() {
|
|
796
|
-
return purry(_groupBy(false),
|
|
802
|
+
function groupBy(...args) {
|
|
803
|
+
return purry(_groupBy(false), args);
|
|
797
804
|
}
|
|
798
805
|
function _groupBy(indexed) {
|
|
799
806
|
return (array, fn) => {
|
|
@@ -812,16 +819,16 @@ function _groupBy(indexed) {
|
|
|
812
819
|
};
|
|
813
820
|
}
|
|
814
821
|
((groupBy2) => {
|
|
815
|
-
function indexed() {
|
|
816
|
-
return purry(_groupBy(true),
|
|
822
|
+
function indexed(...args) {
|
|
823
|
+
return purry(_groupBy(true), args);
|
|
817
824
|
}
|
|
818
825
|
groupBy2.indexed = indexed;
|
|
819
826
|
groupBy2.strict = groupBy2;
|
|
820
827
|
})(groupBy || (groupBy = {}));
|
|
821
828
|
|
|
822
829
|
// src/array/index-by.ts
|
|
823
|
-
function indexBy() {
|
|
824
|
-
return purry(_indexBy(false),
|
|
830
|
+
function indexBy(...args) {
|
|
831
|
+
return purry(_indexBy(false), args);
|
|
825
832
|
}
|
|
826
833
|
function _indexBy(indexed) {
|
|
827
834
|
return (array, fn) => {
|
|
@@ -834,15 +841,15 @@ function _indexBy(indexed) {
|
|
|
834
841
|
};
|
|
835
842
|
}
|
|
836
843
|
((indexBy2) => {
|
|
837
|
-
function indexed() {
|
|
838
|
-
return purry(_indexBy(true),
|
|
844
|
+
function indexed(...args) {
|
|
845
|
+
return purry(_indexBy(true), args);
|
|
839
846
|
}
|
|
840
847
|
indexBy2.indexed = indexed;
|
|
841
848
|
})(indexBy || (indexBy = {}));
|
|
842
849
|
|
|
843
850
|
// src/array/intersection.ts
|
|
844
|
-
function intersection() {
|
|
845
|
-
return purry(_intersection,
|
|
851
|
+
function intersection(...args) {
|
|
852
|
+
return purry(_intersection, args, intersection.lazy);
|
|
846
853
|
}
|
|
847
854
|
function _intersection(array, other) {
|
|
848
855
|
const lazy = intersection.lazy(other);
|
|
@@ -869,8 +876,8 @@ function _intersection(array, other) {
|
|
|
869
876
|
})(intersection || (intersection = {}));
|
|
870
877
|
|
|
871
878
|
// src/array/intersection-with.ts
|
|
872
|
-
function intersectionWith() {
|
|
873
|
-
return purry(_intersectionWith,
|
|
879
|
+
function intersectionWith(...args) {
|
|
880
|
+
return purry(_intersectionWith, args, intersectionWith.lazy);
|
|
874
881
|
}
|
|
875
882
|
function _intersectionWith(array, other, comparator) {
|
|
876
883
|
const lazy = intersectionWith.lazy(other, comparator);
|
|
@@ -896,32 +903,32 @@ function _intersectionWith(array, other, comparator) {
|
|
|
896
903
|
})(intersectionWith || (intersectionWith = {}));
|
|
897
904
|
|
|
898
905
|
// src/array/join.ts
|
|
899
|
-
function join() {
|
|
900
|
-
return purry(joinImplementation,
|
|
906
|
+
function join(...args) {
|
|
907
|
+
return purry(joinImplementation, args);
|
|
901
908
|
}
|
|
902
909
|
function joinImplementation(data, glue) {
|
|
903
910
|
return data.join(glue);
|
|
904
911
|
}
|
|
905
912
|
|
|
906
913
|
// src/array/last.ts
|
|
907
|
-
function last() {
|
|
908
|
-
return purry(_last,
|
|
914
|
+
function last(...args) {
|
|
915
|
+
return purry(_last, args);
|
|
909
916
|
}
|
|
910
917
|
function _last(array) {
|
|
911
918
|
return array[array.length - 1];
|
|
912
919
|
}
|
|
913
920
|
|
|
914
921
|
// src/array/length.ts
|
|
915
|
-
function length() {
|
|
916
|
-
return purry(_length,
|
|
922
|
+
function length(...args) {
|
|
923
|
+
return purry(_length, args);
|
|
917
924
|
}
|
|
918
925
|
function _length(items) {
|
|
919
926
|
return "length" in items ? items.length : Array.from(items).length;
|
|
920
927
|
}
|
|
921
928
|
|
|
922
929
|
// src/array/map.ts
|
|
923
|
-
function map() {
|
|
924
|
-
return purry(_map(false),
|
|
930
|
+
function map(...args) {
|
|
931
|
+
return purry(_map(false), args, map.lazy);
|
|
925
932
|
}
|
|
926
933
|
function _map(indexed) {
|
|
927
934
|
return (array, fn) => {
|
|
@@ -944,8 +951,8 @@ function _lazy5(indexed) {
|
|
|
944
951
|
};
|
|
945
952
|
}
|
|
946
953
|
((map2) => {
|
|
947
|
-
function indexed() {
|
|
948
|
-
return purry(_map(true),
|
|
954
|
+
function indexed(...args) {
|
|
955
|
+
return purry(_map(true), args, map2.lazyIndexed);
|
|
949
956
|
}
|
|
950
957
|
map2.indexed = indexed;
|
|
951
958
|
map2.lazy = _lazy5(false);
|
|
@@ -954,8 +961,8 @@ function _lazy5(indexed) {
|
|
|
954
961
|
})(map || (map = {}));
|
|
955
962
|
|
|
956
963
|
// src/array/map-to-obj.ts
|
|
957
|
-
function mapToObj() {
|
|
958
|
-
return purry(_mapToObj(false),
|
|
964
|
+
function mapToObj(...args) {
|
|
965
|
+
return purry(_mapToObj(false), args);
|
|
959
966
|
}
|
|
960
967
|
function _mapToObj(indexed) {
|
|
961
968
|
return (array, fn) => {
|
|
@@ -967,8 +974,8 @@ function _mapToObj(indexed) {
|
|
|
967
974
|
};
|
|
968
975
|
}
|
|
969
976
|
((mapToObj2) => {
|
|
970
|
-
function indexed() {
|
|
971
|
-
return purry(_mapToObj(true),
|
|
977
|
+
function indexed(...args) {
|
|
978
|
+
return purry(_mapToObj(true), args);
|
|
972
979
|
}
|
|
973
980
|
mapToObj2.indexed = indexed;
|
|
974
981
|
})(mapToObj || (mapToObj = {}));
|
|
@@ -988,12 +995,12 @@ function _maxBy(indexed) {
|
|
|
988
995
|
return ret;
|
|
989
996
|
};
|
|
990
997
|
}
|
|
991
|
-
function maxBy() {
|
|
992
|
-
return purry(_maxBy(false),
|
|
998
|
+
function maxBy(...args) {
|
|
999
|
+
return purry(_maxBy(false), args);
|
|
993
1000
|
}
|
|
994
1001
|
((maxBy2) => {
|
|
995
|
-
function indexed() {
|
|
996
|
-
return purry(_maxBy(true),
|
|
1002
|
+
function indexed(...args) {
|
|
1003
|
+
return purry(_maxBy(true), args);
|
|
997
1004
|
}
|
|
998
1005
|
maxBy2.indexed = indexed;
|
|
999
1006
|
})(maxBy || (maxBy = {}));
|
|
@@ -1011,12 +1018,12 @@ function _meanBy(indexed) {
|
|
|
1011
1018
|
return sum / array.length;
|
|
1012
1019
|
};
|
|
1013
1020
|
}
|
|
1014
|
-
function meanBy() {
|
|
1015
|
-
return purry(_meanBy(false),
|
|
1021
|
+
function meanBy(...args) {
|
|
1022
|
+
return purry(_meanBy(false), args);
|
|
1016
1023
|
}
|
|
1017
1024
|
((meanBy2) => {
|
|
1018
|
-
function indexed() {
|
|
1019
|
-
return purry(_meanBy(true),
|
|
1025
|
+
function indexed(...args) {
|
|
1026
|
+
return purry(_meanBy(true), args);
|
|
1020
1027
|
}
|
|
1021
1028
|
meanBy2.indexed = indexed;
|
|
1022
1029
|
})(meanBy || (meanBy = {}));
|
|
@@ -1041,19 +1048,19 @@ function _minBy(indexed) {
|
|
|
1041
1048
|
return ret;
|
|
1042
1049
|
};
|
|
1043
1050
|
}
|
|
1044
|
-
function minBy() {
|
|
1045
|
-
return purry(_minBy(false),
|
|
1051
|
+
function minBy(...args) {
|
|
1052
|
+
return purry(_minBy(false), args);
|
|
1046
1053
|
}
|
|
1047
1054
|
((minBy2) => {
|
|
1048
|
-
function indexed() {
|
|
1049
|
-
return purry(_minBy(true),
|
|
1055
|
+
function indexed(...args) {
|
|
1056
|
+
return purry(_minBy(true), args);
|
|
1050
1057
|
}
|
|
1051
1058
|
minBy2.indexed = indexed;
|
|
1052
1059
|
})(minBy || (minBy = {}));
|
|
1053
1060
|
|
|
1054
1061
|
// src/array/partition.ts
|
|
1055
|
-
function partition() {
|
|
1056
|
-
return purry(_partition(false),
|
|
1062
|
+
function partition(...args) {
|
|
1063
|
+
return purry(_partition(false), args);
|
|
1057
1064
|
}
|
|
1058
1065
|
function _partition(indexed) {
|
|
1059
1066
|
return (array, fn) => {
|
|
@@ -1066,15 +1073,15 @@ function _partition(indexed) {
|
|
|
1066
1073
|
};
|
|
1067
1074
|
}
|
|
1068
1075
|
((partition2) => {
|
|
1069
|
-
function indexed() {
|
|
1070
|
-
return purry(_partition(true),
|
|
1076
|
+
function indexed(...args) {
|
|
1077
|
+
return purry(_partition(true), args);
|
|
1071
1078
|
}
|
|
1072
1079
|
partition2.indexed = indexed;
|
|
1073
1080
|
})(partition || (partition = {}));
|
|
1074
1081
|
|
|
1075
1082
|
// src/array/range.ts
|
|
1076
|
-
function range() {
|
|
1077
|
-
return purry(_range,
|
|
1083
|
+
function range(...args) {
|
|
1084
|
+
return purry(_range, args);
|
|
1078
1085
|
}
|
|
1079
1086
|
function _range(start, end) {
|
|
1080
1087
|
const ret = [];
|
|
@@ -1085,8 +1092,8 @@ function _range(start, end) {
|
|
|
1085
1092
|
}
|
|
1086
1093
|
|
|
1087
1094
|
// src/array/reduce.ts
|
|
1088
|
-
function reduce() {
|
|
1089
|
-
return purry(_reduce(false),
|
|
1095
|
+
function reduce(...args) {
|
|
1096
|
+
return purry(_reduce(false), args);
|
|
1090
1097
|
}
|
|
1091
1098
|
function _reduce(indexed) {
|
|
1092
1099
|
return (items, fn, initialValue) => {
|
|
@@ -1097,15 +1104,15 @@ function _reduce(indexed) {
|
|
|
1097
1104
|
};
|
|
1098
1105
|
}
|
|
1099
1106
|
((reduce2) => {
|
|
1100
|
-
function indexed() {
|
|
1101
|
-
return purry(_reduce(true),
|
|
1107
|
+
function indexed(...args) {
|
|
1108
|
+
return purry(_reduce(true), args);
|
|
1102
1109
|
}
|
|
1103
1110
|
reduce2.indexed = indexed;
|
|
1104
1111
|
})(reduce || (reduce = {}));
|
|
1105
1112
|
|
|
1106
1113
|
// src/array/reject.ts
|
|
1107
|
-
function reject() {
|
|
1108
|
-
return purry(_reject(false),
|
|
1114
|
+
function reject(...args) {
|
|
1115
|
+
return purry(_reject(false), args, reject.lazy);
|
|
1109
1116
|
}
|
|
1110
1117
|
function _reject(indexed) {
|
|
1111
1118
|
return (array, fn) => {
|
|
@@ -1135,8 +1142,8 @@ function _lazy6(indexed) {
|
|
|
1135
1142
|
};
|
|
1136
1143
|
}
|
|
1137
1144
|
((reject2) => {
|
|
1138
|
-
function indexed() {
|
|
1139
|
-
return purry(_reject(true),
|
|
1145
|
+
function indexed(...args) {
|
|
1146
|
+
return purry(_reject(true), args, reject2.lazyIndexed);
|
|
1140
1147
|
}
|
|
1141
1148
|
reject2.indexed = indexed;
|
|
1142
1149
|
reject2.lazy = _lazy6(false);
|
|
@@ -1144,8 +1151,8 @@ function _lazy6(indexed) {
|
|
|
1144
1151
|
})(reject || (reject = {}));
|
|
1145
1152
|
|
|
1146
1153
|
// src/array/reverse.ts
|
|
1147
|
-
function reverse() {
|
|
1148
|
-
return purry(_reverse,
|
|
1154
|
+
function reverse(...args) {
|
|
1155
|
+
return purry(_reverse, args);
|
|
1149
1156
|
}
|
|
1150
1157
|
function _reverse(array) {
|
|
1151
1158
|
return array.slice().reverse();
|
|
@@ -1181,8 +1188,8 @@ function sampleImplementation(data, sampleSize) {
|
|
|
1181
1188
|
}
|
|
1182
1189
|
|
|
1183
1190
|
// src/array/shuffle.ts
|
|
1184
|
-
function shuffle() {
|
|
1185
|
-
return purry(_shuffle,
|
|
1191
|
+
function shuffle(...args) {
|
|
1192
|
+
return purry(_shuffle, args);
|
|
1186
1193
|
}
|
|
1187
1194
|
function _shuffle(items) {
|
|
1188
1195
|
const result = items.slice();
|
|
@@ -1196,8 +1203,8 @@ function _shuffle(items) {
|
|
|
1196
1203
|
}
|
|
1197
1204
|
|
|
1198
1205
|
// src/array/sort.ts
|
|
1199
|
-
function sort() {
|
|
1200
|
-
return purry(_sort,
|
|
1206
|
+
function sort(...args) {
|
|
1207
|
+
return purry(_sort, args);
|
|
1201
1208
|
}
|
|
1202
1209
|
function _sort(items, cmp) {
|
|
1203
1210
|
const ret = [...items];
|
|
@@ -1215,17 +1222,7 @@ var COMPARATOR = {
|
|
|
1215
1222
|
desc: (x, y) => x < y
|
|
1216
1223
|
};
|
|
1217
1224
|
function sortBy(arrayOrSortRule, ...sortRules) {
|
|
1218
|
-
const args = isSortRule(arrayOrSortRule) ?
|
|
1219
|
-
// *data-last invocation*: put all sort rules into a single array to be
|
|
1220
|
-
// passed as the first param.
|
|
1221
|
-
[[arrayOrSortRule, ...sortRules]]
|
|
1222
|
-
) : (
|
|
1223
|
-
// *data-first invocation*: put the arrayOrSort (which is array now) as
|
|
1224
|
-
// the first param, and all the sorts (as an array) into the second param.
|
|
1225
|
-
// `purry` would pick the right "flavour" based on the length of the
|
|
1226
|
-
// params tuple.
|
|
1227
|
-
[arrayOrSortRule, sortRules]
|
|
1228
|
-
);
|
|
1225
|
+
const args = isSortRule(arrayOrSortRule) ? [[arrayOrSortRule, ...sortRules]] : [arrayOrSortRule, sortRules];
|
|
1229
1226
|
return purry(_sortBy, args);
|
|
1230
1227
|
}
|
|
1231
1228
|
function isSortRule(x) {
|
|
@@ -1263,8 +1260,8 @@ function comparer(primaryRule, secondaryRule, ...otherRules) {
|
|
|
1263
1260
|
})(sortBy || (sortBy = {}));
|
|
1264
1261
|
|
|
1265
1262
|
// src/array/split-at.ts
|
|
1266
|
-
function splitAt() {
|
|
1267
|
-
return purry(_splitAt,
|
|
1263
|
+
function splitAt(...args) {
|
|
1264
|
+
return purry(_splitAt, args);
|
|
1268
1265
|
}
|
|
1269
1266
|
function _splitAt(array, index) {
|
|
1270
1267
|
const copy = [...array];
|
|
@@ -1273,8 +1270,8 @@ function _splitAt(array, index) {
|
|
|
1273
1270
|
}
|
|
1274
1271
|
|
|
1275
1272
|
// src/array/split-when.ts
|
|
1276
|
-
function splitWhen() {
|
|
1277
|
-
return purry(_splitWhen,
|
|
1273
|
+
function splitWhen(...args) {
|
|
1274
|
+
return purry(_splitWhen, args);
|
|
1278
1275
|
}
|
|
1279
1276
|
function _splitWhen(array, fn) {
|
|
1280
1277
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -1296,12 +1293,12 @@ function _sumBy(indexed) {
|
|
|
1296
1293
|
return sum;
|
|
1297
1294
|
};
|
|
1298
1295
|
}
|
|
1299
|
-
function sumBy() {
|
|
1300
|
-
return purry(_sumBy(false),
|
|
1296
|
+
function sumBy(...args) {
|
|
1297
|
+
return purry(_sumBy(false), args);
|
|
1301
1298
|
}
|
|
1302
1299
|
((sumBy2) => {
|
|
1303
|
-
function indexed() {
|
|
1304
|
-
return purry(_sumBy(true),
|
|
1300
|
+
function indexed(...args) {
|
|
1301
|
+
return purry(_sumBy(true), args);
|
|
1305
1302
|
}
|
|
1306
1303
|
sumBy2.indexed = indexed;
|
|
1307
1304
|
})(sumBy || (sumBy = {}));
|
|
@@ -1336,8 +1333,8 @@ function _swapString(item, index1, index2) {
|
|
|
1336
1333
|
}
|
|
1337
1334
|
|
|
1338
1335
|
// src/array/take.ts
|
|
1339
|
-
function take() {
|
|
1340
|
-
return purry(_take,
|
|
1336
|
+
function take(...args) {
|
|
1337
|
+
return purry(_take, args, take.lazy);
|
|
1341
1338
|
}
|
|
1342
1339
|
function _take(array, n) {
|
|
1343
1340
|
return _reduceLazy(array, take.lazy(n));
|
|
@@ -1370,8 +1367,8 @@ function _take(array, n) {
|
|
|
1370
1367
|
})(take || (take = {}));
|
|
1371
1368
|
|
|
1372
1369
|
// src/array/take-while.ts
|
|
1373
|
-
function takeWhile() {
|
|
1374
|
-
return purry(_takeWhile,
|
|
1370
|
+
function takeWhile(...args) {
|
|
1371
|
+
return purry(_takeWhile, args);
|
|
1375
1372
|
}
|
|
1376
1373
|
function _takeWhile(array, fn) {
|
|
1377
1374
|
const ret = [];
|
|
@@ -1385,8 +1382,8 @@ function _takeWhile(array, fn) {
|
|
|
1385
1382
|
}
|
|
1386
1383
|
|
|
1387
1384
|
// src/array/uniq.ts
|
|
1388
|
-
function uniq() {
|
|
1389
|
-
return purry(_uniq,
|
|
1385
|
+
function uniq(...args) {
|
|
1386
|
+
return purry(_uniq, args, uniq.lazy);
|
|
1390
1387
|
}
|
|
1391
1388
|
function _uniq(array) {
|
|
1392
1389
|
return _reduceLazy(array, uniq.lazy());
|
|
@@ -1413,8 +1410,8 @@ function _uniq(array) {
|
|
|
1413
1410
|
})(uniq || (uniq = {}));
|
|
1414
1411
|
|
|
1415
1412
|
// src/array/uniq-by.ts
|
|
1416
|
-
function uniqBy() {
|
|
1417
|
-
return purry(_uniqBy,
|
|
1413
|
+
function uniqBy(...args) {
|
|
1414
|
+
return purry(_uniqBy, args, lazyUniqBy);
|
|
1418
1415
|
}
|
|
1419
1416
|
function _uniqBy(array, transformer) {
|
|
1420
1417
|
return _reduceLazy(array, lazyUniqBy(transformer));
|
|
@@ -1439,8 +1436,8 @@ function lazyUniqBy(transformer) {
|
|
|
1439
1436
|
}
|
|
1440
1437
|
|
|
1441
1438
|
// src/array/uniq-with.ts
|
|
1442
|
-
function uniqWith() {
|
|
1443
|
-
return purry(_uniqWith,
|
|
1439
|
+
function uniqWith(...args) {
|
|
1440
|
+
return purry(_uniqWith, args, uniqWith.lazy);
|
|
1444
1441
|
}
|
|
1445
1442
|
function _uniqWith(array, isEquals) {
|
|
1446
1443
|
const lazy = uniqWith.lazy(isEquals);
|
|
@@ -1466,8 +1463,8 @@ function _lazy7(isEquals) {
|
|
|
1466
1463
|
})(uniqWith || (uniqWith = {}));
|
|
1467
1464
|
|
|
1468
1465
|
// src/array/zip.ts
|
|
1469
|
-
function zip() {
|
|
1470
|
-
return purry(_zip,
|
|
1466
|
+
function zip(...args) {
|
|
1467
|
+
return purry(_zip, args);
|
|
1471
1468
|
}
|
|
1472
1469
|
function _zip(first2, second) {
|
|
1473
1470
|
const resultLength = first2.length > second.length ? second.length : first2.length;
|
|
@@ -1479,8 +1476,8 @@ function _zip(first2, second) {
|
|
|
1479
1476
|
}
|
|
1480
1477
|
|
|
1481
1478
|
// src/array/zip-obj.ts
|
|
1482
|
-
function zipObj() {
|
|
1483
|
-
return purry(_zipObj,
|
|
1479
|
+
function zipObj(...args) {
|
|
1480
|
+
return purry(_zipObj, args);
|
|
1484
1481
|
}
|
|
1485
1482
|
function _zipObj(first2, second) {
|
|
1486
1483
|
const resultLength = first2.length > second.length ? second.length : first2.length;
|
|
@@ -1492,8 +1489,7 @@ function _zipObj(first2, second) {
|
|
|
1492
1489
|
}
|
|
1493
1490
|
|
|
1494
1491
|
// src/array/zip-with.ts
|
|
1495
|
-
function zipWith() {
|
|
1496
|
-
const args = Array.from(arguments);
|
|
1492
|
+
function zipWith(...args) {
|
|
1497
1493
|
if (typeof args[0] === "function" && args.length === 1) {
|
|
1498
1494
|
return function(f, s) {
|
|
1499
1495
|
return _zipWith(f, s, args[0]);
|
|
@@ -1517,51 +1513,9 @@ function _zipWith(first2, second, fn) {
|
|
|
1517
1513
|
return result;
|
|
1518
1514
|
}
|
|
1519
1515
|
|
|
1520
|
-
// src/helpers/index.ts
|
|
1521
|
-
function convertToUnit(str, unit = "px") {
|
|
1522
|
-
if (isNil(str) || str === "") {
|
|
1523
|
-
return void 0;
|
|
1524
|
-
} else if (Number.isNaN(+str)) {
|
|
1525
|
-
return String(str);
|
|
1526
|
-
} else if (!Number.isFinite(+str)) {
|
|
1527
|
-
return void 0;
|
|
1528
|
-
} else {
|
|
1529
|
-
return `${Number(str)}${unit}`;
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
function increaseWithUnit({ target, delta }) {
|
|
1533
|
-
if (isNumber(target)) {
|
|
1534
|
-
return target + delta;
|
|
1535
|
-
}
|
|
1536
|
-
const value = target.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
|
|
1537
|
-
const unit = target.slice(value.length);
|
|
1538
|
-
const result = Number.parseFloat(value) + delta;
|
|
1539
|
-
if (Number.isNaN(result)) {
|
|
1540
|
-
return target;
|
|
1541
|
-
}
|
|
1542
|
-
return result + unit;
|
|
1543
|
-
}
|
|
1544
|
-
function humanReadableFileSize(bytes, base = 1e3) {
|
|
1545
|
-
if (bytes < base) {
|
|
1546
|
-
return `${bytes} B`;
|
|
1547
|
-
}
|
|
1548
|
-
const prefix = base === 1024 ? ["Ki", "Mi", "Gi"] : ["k", "M", "G"];
|
|
1549
|
-
let unit = -1;
|
|
1550
|
-
while (Math.abs(bytes) >= base && unit < prefix.length - 1) {
|
|
1551
|
-
bytes /= base;
|
|
1552
|
-
++unit;
|
|
1553
|
-
}
|
|
1554
|
-
return `${bytes.toFixed(1)} ${prefix[unit]}B`;
|
|
1555
|
-
}
|
|
1556
|
-
function sleep(timeout) {
|
|
1557
|
-
return new Promise((resolve) => {
|
|
1558
|
-
setTimeout(resolve, timeout);
|
|
1559
|
-
});
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
1516
|
// src/number/clamp.ts
|
|
1563
|
-
function clamp() {
|
|
1564
|
-
return purry(_clamp,
|
|
1517
|
+
function clamp(...args) {
|
|
1518
|
+
return purry(_clamp, args);
|
|
1565
1519
|
}
|
|
1566
1520
|
function _clamp(value, limits) {
|
|
1567
1521
|
if (limits.min != null && limits.min > value) {
|
|
@@ -1586,7 +1540,13 @@ function _addProp(obj, prop2, value) {
|
|
|
1586
1540
|
|
|
1587
1541
|
// src/type/type.ts
|
|
1588
1542
|
function type(val) {
|
|
1589
|
-
|
|
1543
|
+
if (val === null) {
|
|
1544
|
+
return "Null";
|
|
1545
|
+
}
|
|
1546
|
+
if (val === void 0) {
|
|
1547
|
+
return "Undefined";
|
|
1548
|
+
}
|
|
1549
|
+
return Object.prototype.toString.call(val).slice(8, -1);
|
|
1590
1550
|
}
|
|
1591
1551
|
|
|
1592
1552
|
// src/object/clone.ts
|
|
@@ -1633,8 +1593,8 @@ function clone(value) {
|
|
|
1633
1593
|
// src/object/equals.ts
|
|
1634
1594
|
var isArray2 = Array.isArray;
|
|
1635
1595
|
var keyList = Object.keys;
|
|
1636
|
-
function equals() {
|
|
1637
|
-
return purry(_equals,
|
|
1596
|
+
function equals(...args) {
|
|
1597
|
+
return purry(_equals, args);
|
|
1638
1598
|
}
|
|
1639
1599
|
function _equals(a, b) {
|
|
1640
1600
|
if (a === b) {
|
|
@@ -1699,8 +1659,8 @@ function _equals(a, b) {
|
|
|
1699
1659
|
}
|
|
1700
1660
|
|
|
1701
1661
|
// src/object/for-each-obj.ts
|
|
1702
|
-
function forEachObj() {
|
|
1703
|
-
return purry(_forEachObj(false),
|
|
1662
|
+
function forEachObj(...args) {
|
|
1663
|
+
return purry(_forEachObj(false), args);
|
|
1704
1664
|
}
|
|
1705
1665
|
function _forEachObj(indexed) {
|
|
1706
1666
|
return (object, fn) => {
|
|
@@ -1718,8 +1678,8 @@ function _forEachObj(indexed) {
|
|
|
1718
1678
|
};
|
|
1719
1679
|
}
|
|
1720
1680
|
((forEachObj2) => {
|
|
1721
|
-
function indexed() {
|
|
1722
|
-
return purry(_forEachObj(true),
|
|
1681
|
+
function indexed(...args) {
|
|
1682
|
+
return purry(_forEachObj(true), args);
|
|
1723
1683
|
}
|
|
1724
1684
|
forEachObj2.indexed = indexed;
|
|
1725
1685
|
})(forEachObj || (forEachObj = {}));
|
|
@@ -1737,8 +1697,8 @@ function fromPairs(entries) {
|
|
|
1737
1697
|
})(fromPairs || (fromPairs = {}));
|
|
1738
1698
|
|
|
1739
1699
|
// src/object/invert.ts
|
|
1740
|
-
function invert() {
|
|
1741
|
-
return purry(_invert,
|
|
1700
|
+
function invert(...args) {
|
|
1701
|
+
return purry(_invert, args);
|
|
1742
1702
|
}
|
|
1743
1703
|
function _invert(object) {
|
|
1744
1704
|
const result = {};
|
|
@@ -1785,16 +1745,16 @@ function _mapValues(obj, fn) {
|
|
|
1785
1745
|
}
|
|
1786
1746
|
|
|
1787
1747
|
// src/object/merge.ts
|
|
1788
|
-
function merge() {
|
|
1789
|
-
return purry(_merge,
|
|
1748
|
+
function merge(...args) {
|
|
1749
|
+
return purry(_merge, args);
|
|
1790
1750
|
}
|
|
1791
1751
|
function _merge(a, b) {
|
|
1792
1752
|
return Object.assign({}, a, b);
|
|
1793
1753
|
}
|
|
1794
1754
|
|
|
1795
1755
|
// src/object/omit.ts
|
|
1796
|
-
function omit() {
|
|
1797
|
-
return purry(_omit,
|
|
1756
|
+
function omit(...args) {
|
|
1757
|
+
return purry(_omit, args);
|
|
1798
1758
|
}
|
|
1799
1759
|
function _omit(data, propNames) {
|
|
1800
1760
|
if (propNames.length === 0) {
|
|
@@ -1803,7 +1763,6 @@ function _omit(data, propNames) {
|
|
|
1803
1763
|
if (propNames.length === 1) {
|
|
1804
1764
|
const [propName] = propNames;
|
|
1805
1765
|
const {
|
|
1806
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- use destructuring to remove a single key, letting JS optimize here...
|
|
1807
1766
|
[propName]: omitted,
|
|
1808
1767
|
...remaining
|
|
1809
1768
|
} = data;
|
|
@@ -1819,8 +1778,8 @@ function _omit(data, propNames) {
|
|
|
1819
1778
|
}
|
|
1820
1779
|
|
|
1821
1780
|
// src/object/omit-by.ts
|
|
1822
|
-
function omitBy() {
|
|
1823
|
-
return purry(_omitBy,
|
|
1781
|
+
function omitBy(...args) {
|
|
1782
|
+
return purry(_omitBy, args);
|
|
1824
1783
|
}
|
|
1825
1784
|
function _omitBy(object, fn) {
|
|
1826
1785
|
return Object.keys(object).reduce((acc, key) => {
|
|
@@ -1832,8 +1791,8 @@ function _omitBy(object, fn) {
|
|
|
1832
1791
|
}
|
|
1833
1792
|
|
|
1834
1793
|
// src/object/path-or.ts
|
|
1835
|
-
function pathOr() {
|
|
1836
|
-
return purry(_pathOr,
|
|
1794
|
+
function pathOr(...args) {
|
|
1795
|
+
return purry(_pathOr, args);
|
|
1837
1796
|
}
|
|
1838
1797
|
function _pathOr(object, path, defaultValue) {
|
|
1839
1798
|
let current = object;
|
|
@@ -1847,8 +1806,8 @@ function _pathOr(object, path, defaultValue) {
|
|
|
1847
1806
|
}
|
|
1848
1807
|
|
|
1849
1808
|
// src/object/pick.ts
|
|
1850
|
-
function pick() {
|
|
1851
|
-
return purry(_pick,
|
|
1809
|
+
function pick(...args) {
|
|
1810
|
+
return purry(_pick, args);
|
|
1852
1811
|
}
|
|
1853
1812
|
function _pick(object, names) {
|
|
1854
1813
|
if (object == null) {
|
|
@@ -1863,8 +1822,8 @@ function _pick(object, names) {
|
|
|
1863
1822
|
}
|
|
1864
1823
|
|
|
1865
1824
|
// src/object/pick-by.ts
|
|
1866
|
-
function pickBy() {
|
|
1867
|
-
return purry(_pickBy,
|
|
1825
|
+
function pickBy(...args) {
|
|
1826
|
+
return purry(_pickBy, args);
|
|
1868
1827
|
}
|
|
1869
1828
|
function _pickBy(object, fn) {
|
|
1870
1829
|
if (object == null) {
|
|
@@ -1884,8 +1843,8 @@ function prop(propName) {
|
|
|
1884
1843
|
}
|
|
1885
1844
|
|
|
1886
1845
|
// src/object/set.ts
|
|
1887
|
-
function set() {
|
|
1888
|
-
return purry(_set,
|
|
1846
|
+
function set(...args) {
|
|
1847
|
+
return purry(_set, args);
|
|
1889
1848
|
}
|
|
1890
1849
|
function _set(obj, prop2, value) {
|
|
1891
1850
|
return {
|
|
@@ -1895,8 +1854,8 @@ function _set(obj, prop2, value) {
|
|
|
1895
1854
|
}
|
|
1896
1855
|
|
|
1897
1856
|
// src/object/set-path.ts
|
|
1898
|
-
function setPath() {
|
|
1899
|
-
return purry(_setPath,
|
|
1857
|
+
function setPath(...args) {
|
|
1858
|
+
return purry(_setPath, args);
|
|
1900
1859
|
}
|
|
1901
1860
|
function _setPath(object, path, defaultValue) {
|
|
1902
1861
|
if (path.length === 0) {
|
|
@@ -1917,8 +1876,8 @@ function _setPath(object, path, defaultValue) {
|
|
|
1917
1876
|
}
|
|
1918
1877
|
|
|
1919
1878
|
// src/object/swap-props.ts
|
|
1920
|
-
function swapProps() {
|
|
1921
|
-
return purry(_swapProps,
|
|
1879
|
+
function swapProps(...args) {
|
|
1880
|
+
return purry(_swapProps, args);
|
|
1922
1881
|
}
|
|
1923
1882
|
function _swapProps(obj, key1, key2) {
|
|
1924
1883
|
const { [key1]: value1, [key2]: value2 } = obj;
|
|
@@ -2013,6 +1972,20 @@ function toSnakeCase(string_) {
|
|
|
2013
1972
|
return toKebabCase(string_ || "", "_");
|
|
2014
1973
|
}
|
|
2015
1974
|
|
|
1975
|
+
// src/string/human-readable-file-size.ts
|
|
1976
|
+
function humanReadableFileSize(bytes, base = 1e3) {
|
|
1977
|
+
if (bytes < base) {
|
|
1978
|
+
return `${bytes} B`;
|
|
1979
|
+
}
|
|
1980
|
+
const prefix = base === 1024 ? ["Ki", "Mi", "Gi"] : ["k", "M", "G"];
|
|
1981
|
+
let unit = -1;
|
|
1982
|
+
while (Math.abs(bytes) >= base && unit < prefix.length - 1) {
|
|
1983
|
+
bytes /= base;
|
|
1984
|
+
++unit;
|
|
1985
|
+
}
|
|
1986
|
+
return `${bytes.toFixed(1)} ${prefix[unit]}B`;
|
|
1987
|
+
}
|
|
1988
|
+
|
|
2016
1989
|
// src/string/random-string.ts
|
|
2017
1990
|
function randomString(length2) {
|
|
2018
1991
|
const characterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
@@ -2020,6 +1993,11 @@ function randomString(length2) {
|
|
|
2020
1993
|
return range(0, length2).reduce((text) => text + randomChar(), "");
|
|
2021
1994
|
}
|
|
2022
1995
|
|
|
1996
|
+
// src/string/slugify.ts
|
|
1997
|
+
function slugify(str) {
|
|
1998
|
+
return str.normalize("NFD").replace(/[\u0300-\u036F]/g, "").toLowerCase().replace(/[^a-z0-9]/g, " ").trim().replace(/\s+/g, "-");
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2023
2001
|
// src/string/string-to-path.ts
|
|
2024
2002
|
function stringToPath(path) {
|
|
2025
2003
|
return _stringToPath(path);
|
|
@@ -2049,7 +2027,6 @@ export {
|
|
|
2049
2027
|
clone,
|
|
2050
2028
|
compact,
|
|
2051
2029
|
concat,
|
|
2052
|
-
convertToUnit,
|
|
2053
2030
|
countBy,
|
|
2054
2031
|
createPipe,
|
|
2055
2032
|
difference,
|
|
@@ -2073,7 +2050,6 @@ export {
|
|
|
2073
2050
|
groupBy,
|
|
2074
2051
|
humanReadableFileSize,
|
|
2075
2052
|
identity,
|
|
2076
|
-
increaseWithUnit,
|
|
2077
2053
|
indexBy,
|
|
2078
2054
|
intersection,
|
|
2079
2055
|
intersectionWith,
|
|
@@ -2129,6 +2105,7 @@ export {
|
|
|
2129
2105
|
setPath,
|
|
2130
2106
|
shuffle,
|
|
2131
2107
|
sleep,
|
|
2108
|
+
slugify,
|
|
2132
2109
|
sort,
|
|
2133
2110
|
sortBy,
|
|
2134
2111
|
splitAt,
|