rambda 10.0.0-beta.1 → 10.0.0

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/index.d.ts CHANGED
@@ -41,7 +41,7 @@ export type DeepModify<Keys extends readonly PropertyKey[], U, T> =
41
41
  : never;
42
42
 
43
43
 
44
- export type PickStringToPickPath<T> = T extends `${infer Head},${infer Tail}` ? [Head, ...PickStringToPickPath<Tail>]
44
+ export type PickStringToPickPath<T> = T extends `${infer Head},${infer Tail}` ? [Head, ...PickStringToPickPath<Tail>]
45
45
  : T extends `${infer Head}` ? [Head]
46
46
  : [];
47
47
 
@@ -88,6 +88,39 @@ MergeTypes<
88
88
 
89
89
  type StrictNonNullable<T> = Exclude<T, null | undefined>;
90
90
 
91
+ type Flatten<T> = T extends object
92
+ ? T extends readonly any[]
93
+ ? T
94
+ : {
95
+ [K in keyof T]-?: NonNullable<T[K]> extends infer V
96
+ ? V extends object
97
+ ? V extends readonly any[]
98
+ ? never
99
+ : Flatten<V>
100
+ : V
101
+ : never
102
+ }
103
+ : T;
104
+
105
+ export type FlattenObject<T extends object> = object extends T
106
+ ? object
107
+ : {
108
+ [K in keyof T]-?: (
109
+ x: NonNullable<T[K]> extends infer V
110
+ ? V extends object
111
+ ? V extends readonly any[]
112
+ ? never
113
+ : Flatten<V> extends infer FV
114
+ ? {
115
+ [P in keyof FV as `${Extract<K, string>}.${Extract<P, string>}`]: FV[P]
116
+ }
117
+ : never
118
+ : Pick<T, K>
119
+ : never
120
+ ) => void
121
+ } extends Record<keyof T, (y: infer O) => void>
122
+ ? O
123
+ : never;
91
124
 
92
125
  /**
93
126
  * It adds new key-value pair to the object.
@@ -97,6 +130,20 @@ export function addProp<T extends object, P extends PropertyKey, V extends unkno
97
130
  value: V
98
131
  ): (obj: T) => MergeTypes<T & Record<P, V>>;
99
132
 
133
+ /**
134
+ * It receives list of objects and add new property to each item.
135
+ *
136
+ * The value is based on result of `fn` function, which receives the current object as argument.
137
+ */
138
+ export function addPropToObjects<
139
+ T extends object,
140
+ K extends string,
141
+ R
142
+ >(
143
+ property: K,
144
+ fn: (input: T) => R
145
+ ): (list: T[]) => MergeTypes<T & { [P in K]: R }>[];
146
+
100
147
  /**
101
148
  * It returns `true`, if all members of array `list` returns `true`, when applied as argument to `predicate` function.
102
149
  */
@@ -337,6 +384,11 @@ export function flatMap<T, U extends unknown>(transformFn: (x: T extends any[] ?
337
384
  */
338
385
  export function flatten<T>(list: any[]): T[];
339
386
 
387
+ /**
388
+ * It transforms object to object where each value is represented with its path.
389
+ */
390
+ export function flattenObject<T extends object>(obj: T): FlattenObject<T>;
391
+
340
392
  /**
341
393
  * It splits `list` according to a provided `groupFn` function and returns an object.
342
394
  */
@@ -388,9 +440,7 @@ export function interpolate(inputWithTags: string): (templateArguments: object)
388
440
 
389
441
 
390
442
  // API_MARKER_END
391
- // ============================================
392
-
393
- export as namespace R
443
+ // ===========================================
394
444
 
395
445
  /**
396
446
  * It loops through `listA` and `listB` and returns the intersection of the two according to `R.equals`.
@@ -531,6 +581,11 @@ export function mergeTypes<T>(x: T): MergeTypes<T>;
531
581
  */
532
582
  export function minBy<T>(compareFn: (input: T) => Ord, x: T): (y: T) => T;
533
583
 
584
+ /**
585
+ * It replaces `index` in array `list` with the result of `replaceFn(list[i])`.
586
+ */
587
+ export function modifyItemAtIndex<T>(index: number, replaceFn: (x: T) => T): (list: T[]) => T[];
588
+
534
589
  /**
535
590
  * It changes a property with the result of transformer function.
536
591
  */
@@ -844,6 +899,191 @@ export function path<
844
899
  K8 extends keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
845
900
  >(path: [K0, K1, K2, K3, K4, K5, K6, K7, K8]): (obj: S) => S[K0][K1][K2][K3][K4][K5][K6][K7][K8];
846
901
 
902
+ export function pathSatisfies<S, K0 extends string & keyof S>(
903
+ predicate: (x: S[K0]) => boolean,
904
+ path: [K0]
905
+ ): (obj: S) => boolean;
906
+ export function pathSatisfies<S, K0 extends string & keyof S>(
907
+ predicate: (x: S[K0]) => boolean,
908
+ path: `${K0}`
909
+ ): (obj: S) => boolean;
910
+ export function pathSatisfies<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
911
+ predicate: (x: S[K0][K1]) => boolean,
912
+ path: [K0, K1]
913
+ ): (obj: S) => boolean;
914
+ export function pathSatisfies<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
915
+ predicate: (x: S[K0][K1]) => boolean,
916
+ path: `${K0}.${K1}`
917
+ ): (obj: S) => boolean;
918
+ export function pathSatisfies<
919
+ S,
920
+ K0 extends string & keyof S,
921
+ K1 extends string & keyof S[K0],
922
+ K2 extends string & keyof S[K0][K1]
923
+ >(
924
+ predicate: (x: S[K0][K1][K2]) => boolean,
925
+ path: [K0, K1, K2]
926
+ ): (obj: S) => boolean;
927
+ export function pathSatisfies<
928
+ S,
929
+ K0 extends string & keyof S,
930
+ K1 extends string & keyof S[K0],
931
+ K2 extends string & keyof S[K0][K1]
932
+ >(
933
+ predicate: (x: S[K0][K1][K2]) => boolean,
934
+ path: `${K0}.${K1}.${K2}`
935
+ ): (obj: S) => boolean;
936
+ export function pathSatisfies<
937
+ S,
938
+ K0 extends string & keyof S,
939
+ K1 extends string & keyof S[K0],
940
+ K2 extends string & keyof S[K0][K1],
941
+ K3 extends string & keyof S[K0][K1][K2]
942
+ >(
943
+ predicate: (x: S[K0][K1][K2][K3]) => boolean,
944
+ path: [K0, K1, K2, K3]
945
+ ): (obj: S) => boolean;
946
+ export function pathSatisfies<
947
+ S,
948
+ K0 extends string & keyof S,
949
+ K1 extends string & keyof S[K0],
950
+ K2 extends string & keyof S[K0][K1],
951
+ K3 extends string & keyof S[K0][K1][K2]
952
+ >(
953
+ predicate: (x: S[K0][K1][K2][K3]) => boolean,
954
+ path: `${K0}.${K1}.${K2}.${K3}`
955
+ ): (obj: S) => boolean;
956
+ export function pathSatisfies<
957
+ S,
958
+ K0 extends string & keyof S,
959
+ K1 extends string & keyof S[K0],
960
+ K2 extends string & keyof S[K0][K1],
961
+ K3 extends string & keyof S[K0][K1][K2],
962
+ K4 extends string & keyof S[K0][K1][K2][K3]
963
+ >(
964
+ predicate: (x: S[K0][K1][K2][K3][K4]) => boolean,
965
+ path: [K0, K1, K2, K3, K4]
966
+ ): (obj: S) => boolean;
967
+ export function pathSatisfies<
968
+ S,
969
+ K0 extends string & keyof S,
970
+ K1 extends string & keyof S[K0],
971
+ K2 extends string & keyof S[K0][K1],
972
+ K3 extends string & keyof S[K0][K1][K2],
973
+ K4 extends string & keyof S[K0][K1][K2][K3]
974
+ >(
975
+ predicate: (x: S[K0][K1][K2][K3][K4]) => boolean,
976
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}`
977
+ ): (obj: S) => boolean;
978
+ export function pathSatisfies<
979
+ S,
980
+ K0 extends string & keyof S,
981
+ K1 extends string & keyof S[K0],
982
+ K2 extends string & keyof S[K0][K1],
983
+ K3 extends string & keyof S[K0][K1][K2],
984
+ K4 extends string & keyof S[K0][K1][K2][K3],
985
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
986
+ >(
987
+ predicate: (x: S[K0][K1][K2][K3][K4][K5]) => boolean,
988
+ path: [K0, K1, K2, K3, K4, K5]
989
+ ): (obj: S) => boolean;
990
+ export function pathSatisfies<
991
+ S,
992
+ K0 extends string & keyof S,
993
+ K1 extends string & keyof S[K0],
994
+ K2 extends string & keyof S[K0][K1],
995
+ K3 extends string & keyof S[K0][K1][K2],
996
+ K4 extends string & keyof S[K0][K1][K2][K3],
997
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
998
+ >(
999
+ predicate: (x: S[K0][K1][K2][K3][K4][K5]) => boolean,
1000
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}`
1001
+ ): (obj: S) => boolean;
1002
+ export function pathSatisfies<
1003
+ S,
1004
+ K0 extends string & keyof S,
1005
+ K1 extends string & keyof S[K0],
1006
+ K2 extends string & keyof S[K0][K1],
1007
+ K3 extends string & keyof S[K0][K1][K2],
1008
+ K4 extends string & keyof S[K0][K1][K2][K3],
1009
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1010
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1011
+ >(
1012
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6]) => boolean,
1013
+ path: [K0, K1, K2, K3, K4, K5, K6]
1014
+ ): (obj: S) => boolean;
1015
+ export function pathSatisfies<
1016
+ S,
1017
+ K0 extends string & keyof S,
1018
+ K1 extends string & keyof S[K0],
1019
+ K2 extends string & keyof S[K0][K1],
1020
+ K3 extends string & keyof S[K0][K1][K2],
1021
+ K4 extends string & keyof S[K0][K1][K2][K3],
1022
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1023
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1024
+ >(
1025
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6]) => boolean,
1026
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}`
1027
+ ): (obj: S) => boolean;
1028
+ export function pathSatisfies<
1029
+ S,
1030
+ K0 extends string & keyof S,
1031
+ K1 extends string & keyof S[K0],
1032
+ K2 extends string & keyof S[K0][K1],
1033
+ K3 extends string & keyof S[K0][K1][K2],
1034
+ K4 extends string & keyof S[K0][K1][K2][K3],
1035
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1036
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1037
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
1038
+ >(
1039
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6][K7]) => boolean,
1040
+ path: [K0, K1, K2, K3, K4, K5, K6, K7]
1041
+ ): (obj: S) => boolean;
1042
+ export function pathSatisfies<
1043
+ S,
1044
+ K0 extends string & keyof S,
1045
+ K1 extends string & keyof S[K0],
1046
+ K2 extends string & keyof S[K0][K1],
1047
+ K3 extends string & keyof S[K0][K1][K2],
1048
+ K4 extends string & keyof S[K0][K1][K2][K3],
1049
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1050
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1051
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
1052
+ >(
1053
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6][K7]) => boolean,
1054
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}`
1055
+ ): (obj: S) => boolean;
1056
+ export function pathSatisfies<
1057
+ S,
1058
+ K0 extends string & keyof S,
1059
+ K1 extends string & keyof S[K0],
1060
+ K2 extends string & keyof S[K0][K1],
1061
+ K3 extends string & keyof S[K0][K1][K2],
1062
+ K4 extends string & keyof S[K0][K1][K2][K3],
1063
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1064
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1065
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
1066
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
1067
+ >(
1068
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6][K7][K8]) => boolean,
1069
+ path: [K0, K1, K2, K3, K4, K5, K6, K7, K8]
1070
+ ): (obj: S) => boolean;
1071
+ export function pathSatisfies<
1072
+ S,
1073
+ K0 extends string & keyof S,
1074
+ K1 extends string & keyof S[K0],
1075
+ K2 extends string & keyof S[K0][K1],
1076
+ K3 extends string & keyof S[K0][K1][K2],
1077
+ K4 extends string & keyof S[K0][K1][K2][K3],
1078
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1079
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1080
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
1081
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
1082
+ >(
1083
+ predicate: (x: S[K0][K1][K2][K3][K4][K5][K6][K7][K8]) => boolean,
1084
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}.${K8}`
1085
+ ): (obj: S) => boolean;
1086
+
847
1087
  export function permutations<T>(list: T[]): T[][];
848
1088
 
849
1089
  /**
@@ -1408,15 +1648,11 @@ export function propOr<T, P extends string>(defaultValue: T, property: P): (obj:
1408
1648
  export function propSatisfies<T>(predicate: (x: T) => boolean, property: string): (obj: Record<PropertyKey, T>) => boolean;
1409
1649
 
1410
1650
  /**
1411
- * It returns list of numbers between `startInclusive` to `endInclusive` markers.
1651
+ * It returns list of numbers between `startInclusive` to `endExclusive` markers.
1652
+ * If `start` is greater than `end`, then the result will be in descending order.
1412
1653
  */
1413
1654
  export function range(startInclusive: number): (endExclusive: number) => number[];
1414
1655
 
1415
- /**
1416
- * Same as `R.range` but in descending order.
1417
- */
1418
- export function rangeDescending(startInclusive: number): (endExclusive: number) => number[];
1419
-
1420
1656
  export function reduce<T, TResult>(reducer: (prev: TResult, current: T, i: number) => TResult, initialValue: TResult): (list: T[]) => TResult;
1421
1657
 
1422
1658
  /**
@@ -1452,11 +1688,6 @@ export function rejectObject<T extends object>(
1452
1688
  */
1453
1689
  export function replace(strOrRegex: RegExp | string, replacer: RegExp | string): (str: string) => string;
1454
1690
 
1455
- /**
1456
- * It replaces `index` in array `list` with the result of `replaceFn(list[i])`.
1457
- */
1458
- export function replaceItemAtIndex<T>(index: number, replaceFn: (x: T) => T): (list: T[]) => T[];
1459
-
1460
1691
  /**
1461
1692
  * It returns a randomized copy of array.
1462
1693
  */
@@ -1472,6 +1703,345 @@ export function sort<T>(sortFn: (a: T, b: T) => number): (list: T[]) => T[];
1472
1703
  */
1473
1704
  export function sortBy<T>(sortFn: (x: T) => Ord): (list: T[]) => T[];
1474
1705
 
1706
+ export function sortByDescending<T>(sortFn: (a: T, b: T) => number): (list: T[]) => T[];
1707
+
1708
+ /**
1709
+ * It sorts `list` by the value of `path` property.
1710
+ */
1711
+ export function sortByPath<S, K0 extends string & keyof S>(
1712
+ path: [K0]
1713
+ ): (list: S[]) => S[];
1714
+ export function sortByPath<S, K0 extends string & keyof S>(
1715
+ path: `${K0}`
1716
+ ): (list: S[]) => S[];
1717
+ export function sortByPath<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
1718
+ path: [K0, K1]
1719
+ ): (list: S[]) => S[];
1720
+ export function sortByPath<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
1721
+ path: `${K0}.${K1}`
1722
+ ): (list: S[]) => S[];
1723
+ export function sortByPath<
1724
+ S,
1725
+ K0 extends string & keyof S,
1726
+ K1 extends string & keyof S[K0],
1727
+ K2 extends string & keyof S[K0][K1]
1728
+ >(
1729
+ path: [K0, K1, K2]
1730
+ ): (list: S[]) => S[];
1731
+ export function sortByPath<
1732
+ S,
1733
+ K0 extends string & keyof S,
1734
+ K1 extends string & keyof S[K0],
1735
+ K2 extends string & keyof S[K0][K1]
1736
+ >(
1737
+ path: `${K0}.${K1}.${K2}`
1738
+ ): (list: S[]) => S[];
1739
+ export function sortByPath<
1740
+ S,
1741
+ K0 extends string & keyof S,
1742
+ K1 extends string & keyof S[K0],
1743
+ K2 extends string & keyof S[K0][K1],
1744
+ K3 extends string & keyof S[K0][K1][K2]
1745
+ >(
1746
+ path: [K0, K1, K2, K3]
1747
+ ): (list: S[]) => S[];
1748
+ export function sortByPath<
1749
+ S,
1750
+ K0 extends string & keyof S,
1751
+ K1 extends string & keyof S[K0],
1752
+ K2 extends string & keyof S[K0][K1],
1753
+ K3 extends string & keyof S[K0][K1][K2]
1754
+ >(
1755
+ path: `${K0}.${K1}.${K2}.${K3}`
1756
+ ): (list: S[]) => S[];
1757
+ export function sortByPath<
1758
+ S,
1759
+ K0 extends string & keyof S,
1760
+ K1 extends string & keyof S[K0],
1761
+ K2 extends string & keyof S[K0][K1],
1762
+ K3 extends string & keyof S[K0][K1][K2],
1763
+ K4 extends string & keyof S[K0][K1][K2][K3]
1764
+ >(
1765
+ path: [K0, K1, K2, K3, K4]
1766
+ ): (list: S[]) => S[];
1767
+ export function sortByPath<
1768
+ S,
1769
+ K0 extends string & keyof S,
1770
+ K1 extends string & keyof S[K0],
1771
+ K2 extends string & keyof S[K0][K1],
1772
+ K3 extends string & keyof S[K0][K1][K2],
1773
+ K4 extends string & keyof S[K0][K1][K2][K3]
1774
+ >(
1775
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}`
1776
+ ): (list: S[]) => S[];
1777
+ export function sortByPath<
1778
+ S,
1779
+ K0 extends string & keyof S,
1780
+ K1 extends string & keyof S[K0],
1781
+ K2 extends string & keyof S[K0][K1],
1782
+ K3 extends string & keyof S[K0][K1][K2],
1783
+ K4 extends string & keyof S[K0][K1][K2][K3],
1784
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
1785
+ >(
1786
+ path: [K0, K1, K2, K3, K4, K5]
1787
+ ): (list: S[]) => S[];
1788
+ export function sortByPath<
1789
+ S,
1790
+ K0 extends string & keyof S,
1791
+ K1 extends string & keyof S[K0],
1792
+ K2 extends string & keyof S[K0][K1],
1793
+ K3 extends string & keyof S[K0][K1][K2],
1794
+ K4 extends string & keyof S[K0][K1][K2][K3],
1795
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
1796
+ >(
1797
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}`
1798
+ ): (list: S[]) => S[];
1799
+ export function sortByPath<
1800
+ S,
1801
+ K0 extends string & keyof S,
1802
+ K1 extends string & keyof S[K0],
1803
+ K2 extends string & keyof S[K0][K1],
1804
+ K3 extends string & keyof S[K0][K1][K2],
1805
+ K4 extends string & keyof S[K0][K1][K2][K3],
1806
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1807
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1808
+ >(
1809
+ path: [K0, K1, K2, K3, K4, K5, K6]
1810
+ ): (list: S[]) => S[];
1811
+ export function sortByPath<
1812
+ S,
1813
+ K0 extends string & keyof S,
1814
+ K1 extends string & keyof S[K0],
1815
+ K2 extends string & keyof S[K0][K1],
1816
+ K3 extends string & keyof S[K0][K1][K2],
1817
+ K4 extends string & keyof S[K0][K1][K2][K3],
1818
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1819
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1820
+ >(
1821
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}`
1822
+ ): (list: S[]) => S[];
1823
+ export function sortByPath<
1824
+ S,
1825
+ K0 extends string & keyof S,
1826
+ K1 extends string & keyof S[K0],
1827
+ K2 extends string & keyof S[K0][K1],
1828
+ K3 extends string & keyof S[K0][K1][K2],
1829
+ K4 extends string & keyof S[K0][K1][K2][K3],
1830
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1831
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1832
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
1833
+ >(
1834
+ path: [K0, K1, K2, K3, K4, K5, K6, K7]
1835
+ ): (list: S[]) => S[];
1836
+ export function sortByPath<
1837
+ S,
1838
+ K0 extends string & keyof S,
1839
+ K1 extends string & keyof S[K0],
1840
+ K2 extends string & keyof S[K0][K1],
1841
+ K3 extends string & keyof S[K0][K1][K2],
1842
+ K4 extends string & keyof S[K0][K1][K2][K3],
1843
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1844
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1845
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
1846
+ >(
1847
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}`
1848
+ ): (list: S[]) => S[];
1849
+ export function sortByPath<
1850
+ S,
1851
+ K0 extends string & keyof S,
1852
+ K1 extends string & keyof S[K0],
1853
+ K2 extends string & keyof S[K0][K1],
1854
+ K3 extends string & keyof S[K0][K1][K2],
1855
+ K4 extends string & keyof S[K0][K1][K2][K3],
1856
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1857
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1858
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
1859
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
1860
+ >(
1861
+ path: [K0, K1, K2, K3, K4, K5, K6, K7, K8]
1862
+ ): (list: S[]) => S[];
1863
+ export function sortByPath<
1864
+ S,
1865
+ K0 extends string & keyof S,
1866
+ K1 extends string & keyof S[K0],
1867
+ K2 extends string & keyof S[K0][K1],
1868
+ K3 extends string & keyof S[K0][K1][K2],
1869
+ K4 extends string & keyof S[K0][K1][K2][K3],
1870
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1871
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1872
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
1873
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
1874
+ >(
1875
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}.${K8}`
1876
+ ): (list: S[]) => S[];
1877
+
1878
+ export function sortByPathDescending<S, K0 extends string & keyof S>(
1879
+ path: [K0]
1880
+ ): (list: S[]) => S[];
1881
+ export function sortByPathDescending<S, K0 extends string & keyof S>(
1882
+ path: `${K0}`
1883
+ ): (list: S[]) => S[];
1884
+ export function sortByPathDescending<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
1885
+ path: [K0, K1]
1886
+ ): (list: S[]) => S[];
1887
+ export function sortByPathDescending<S, K0 extends string & keyof S, K1 extends string & keyof S[K0]>(
1888
+ path: `${K0}.${K1}`
1889
+ ): (list: S[]) => S[];
1890
+ export function sortByPathDescending<
1891
+ S,
1892
+ K0 extends string & keyof S,
1893
+ K1 extends string & keyof S[K0],
1894
+ K2 extends string & keyof S[K0][K1]
1895
+ >(
1896
+ path: [K0, K1, K2]
1897
+ ): (list: S[]) => S[];
1898
+ export function sortByPathDescending<
1899
+ S,
1900
+ K0 extends string & keyof S,
1901
+ K1 extends string & keyof S[K0],
1902
+ K2 extends string & keyof S[K0][K1]
1903
+ >(
1904
+ path: `${K0}.${K1}.${K2}`
1905
+ ): (list: S[]) => S[];
1906
+ export function sortByPathDescending<
1907
+ S,
1908
+ K0 extends string & keyof S,
1909
+ K1 extends string & keyof S[K0],
1910
+ K2 extends string & keyof S[K0][K1],
1911
+ K3 extends string & keyof S[K0][K1][K2]
1912
+ >(
1913
+ path: [K0, K1, K2, K3]
1914
+ ): (list: S[]) => S[];
1915
+ export function sortByPathDescending<
1916
+ S,
1917
+ K0 extends string & keyof S,
1918
+ K1 extends string & keyof S[K0],
1919
+ K2 extends string & keyof S[K0][K1],
1920
+ K3 extends string & keyof S[K0][K1][K2]
1921
+ >(
1922
+ path: `${K0}.${K1}.${K2}.${K3}`
1923
+ ): (list: S[]) => S[];
1924
+ export function sortByPathDescending<
1925
+ S,
1926
+ K0 extends string & keyof S,
1927
+ K1 extends string & keyof S[K0],
1928
+ K2 extends string & keyof S[K0][K1],
1929
+ K3 extends string & keyof S[K0][K1][K2],
1930
+ K4 extends string & keyof S[K0][K1][K2][K3]
1931
+ >(
1932
+ path: [K0, K1, K2, K3, K4]
1933
+ ): (list: S[]) => S[];
1934
+ export function sortByPathDescending<
1935
+ S,
1936
+ K0 extends string & keyof S,
1937
+ K1 extends string & keyof S[K0],
1938
+ K2 extends string & keyof S[K0][K1],
1939
+ K3 extends string & keyof S[K0][K1][K2],
1940
+ K4 extends string & keyof S[K0][K1][K2][K3]
1941
+ >(
1942
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}`
1943
+ ): (list: S[]) => S[];
1944
+ export function sortByPathDescending<
1945
+ S,
1946
+ K0 extends string & keyof S,
1947
+ K1 extends string & keyof S[K0],
1948
+ K2 extends string & keyof S[K0][K1],
1949
+ K3 extends string & keyof S[K0][K1][K2],
1950
+ K4 extends string & keyof S[K0][K1][K2][K3],
1951
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
1952
+ >(
1953
+ path: [K0, K1, K2, K3, K4, K5]
1954
+ ): (list: S[]) => S[];
1955
+ export function sortByPathDescending<
1956
+ S,
1957
+ K0 extends string & keyof S,
1958
+ K1 extends string & keyof S[K0],
1959
+ K2 extends string & keyof S[K0][K1],
1960
+ K3 extends string & keyof S[K0][K1][K2],
1961
+ K4 extends string & keyof S[K0][K1][K2][K3],
1962
+ K5 extends string & keyof S[K0][K1][K2][K3][K4]
1963
+ >(
1964
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}`
1965
+ ): (list: S[]) => S[];
1966
+ export function sortByPathDescending<
1967
+ S,
1968
+ K0 extends string & keyof S,
1969
+ K1 extends string & keyof S[K0],
1970
+ K2 extends string & keyof S[K0][K1],
1971
+ K3 extends string & keyof S[K0][K1][K2],
1972
+ K4 extends string & keyof S[K0][K1][K2][K3],
1973
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1974
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1975
+ >(
1976
+ path: [K0, K1, K2, K3, K4, K5, K6]
1977
+ ): (list: S[]) => S[];
1978
+ export function sortByPathDescending<
1979
+ S,
1980
+ K0 extends string & keyof S,
1981
+ K1 extends string & keyof S[K0],
1982
+ K2 extends string & keyof S[K0][K1],
1983
+ K3 extends string & keyof S[K0][K1][K2],
1984
+ K4 extends string & keyof S[K0][K1][K2][K3],
1985
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1986
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5]
1987
+ >(
1988
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}`
1989
+ ): (list: S[]) => S[];
1990
+ export function sortByPathDescending<
1991
+ S,
1992
+ K0 extends string & keyof S,
1993
+ K1 extends string & keyof S[K0],
1994
+ K2 extends string & keyof S[K0][K1],
1995
+ K3 extends string & keyof S[K0][K1][K2],
1996
+ K4 extends string & keyof S[K0][K1][K2][K3],
1997
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
1998
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
1999
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
2000
+ >(
2001
+ path: [K0, K1, K2, K3, K4, K5, K6, K7]
2002
+ ): (list: S[]) => S[];
2003
+ export function sortByPathDescending<
2004
+ S,
2005
+ K0 extends string & keyof S,
2006
+ K1 extends string & keyof S[K0],
2007
+ K2 extends string & keyof S[K0][K1],
2008
+ K3 extends string & keyof S[K0][K1][K2],
2009
+ K4 extends string & keyof S[K0][K1][K2][K3],
2010
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
2011
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
2012
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6]
2013
+ >(
2014
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}`
2015
+ ): (list: S[]) => S[];
2016
+ export function sortByPathDescending<
2017
+ S,
2018
+ K0 extends string & keyof S,
2019
+ K1 extends string & keyof S[K0],
2020
+ K2 extends string & keyof S[K0][K1],
2021
+ K3 extends string & keyof S[K0][K1][K2],
2022
+ K4 extends string & keyof S[K0][K1][K2][K3],
2023
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
2024
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
2025
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
2026
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
2027
+ >(
2028
+ path: [K0, K1, K2, K3, K4, K5, K6, K7, K8]
2029
+ ): (list: S[]) => S[];
2030
+ export function sortByPathDescending<
2031
+ S,
2032
+ K0 extends string & keyof S,
2033
+ K1 extends string & keyof S[K0],
2034
+ K2 extends string & keyof S[K0][K1],
2035
+ K3 extends string & keyof S[K0][K1][K2],
2036
+ K4 extends string & keyof S[K0][K1][K2][K3],
2037
+ K5 extends string & keyof S[K0][K1][K2][K3][K4],
2038
+ K6 extends string & keyof S[K0][K1][K2][K3][K4][K5],
2039
+ K7 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6],
2040
+ K8 extends string & keyof S[K0][K1][K2][K3][K4][K5][K6][K7]
2041
+ >(
2042
+ path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}.${K7}.${K8}`
2043
+ ): (list: S[]) => S[];
2044
+
1475
2045
  /**
1476
2046
  * It returns a sorted version of `input` object.
1477
2047
  */
@@ -1590,7 +2160,7 @@ export function unless<T>(predicate: (x: T) => boolean, whenFalseFn: (x: T) => T
1590
2160
  /**
1591
2161
  * It takes an object and a property name. The method will return a list of objects, where each object is a shallow copy of the input object, but with the property array unwound.
1592
2162
  */
1593
- export function unwind<S extends string>(prop: S): <T>(obj: T) => Omit<T, S> & { [K in S]: T[S][number] };
2163
+ export function unwind<S extends string>(prop: S): <T>(obj: T) => MergeTypes<Omit<T, S> & { [K in S]: T[S][number] }>;
1594
2164
 
1595
2165
  /**
1596
2166
  * It returns a copy of `list` with updated element at `index` with `newValue`.
@@ -1601,6 +2171,7 @@ export function update<T>(index: number, newValue: T): (list: T[]) => T[];
1601
2171
  * It pass `input` to `predicate` function and if the result is `true`, it will return the result of `whenTrueFn(input)`.
1602
2172
  * If the `predicate` returns `false`, then it will simply return `input`.
1603
2173
  */
2174
+ export function when<T, U extends T>(predicate: (x: T) => x is U, whenTrueFn: (x: U) => T): (input: T) => T;
1604
2175
  export function when<T>(predicate: (x: T) => boolean, whenTrueFn: (x: T) => T): (input: T) => T;
1605
2176
  export function when<T, U>(predicate: (x: T) => boolean, whenTrueFn: (x: T) => U): (input: T) => T | U;
1606
2177