rambda 10.0.0-beta.1 → 10.0.0-beta.3

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