@@ -69,6 +69,9 @@ import {
6969 ToTupleOfFunction ,
7070 Tuple ,
7171 CondPairTypeguard ,
72+ Fn ,
73+ IfFunctionsArgumentsDoNotOverlap ,
74+ LargestArgumentsList ,
7275} from './tools' ;
7376
7477export * from './tools' ;
@@ -807,78 +810,28 @@ export function contains<T>(a: T): (list: readonly T[]) => boolean;
807810 * are passed as arguments to the converging function to produce the return value.
808811 */
809812export function converge <
810- TArgs extends any [ ] ,
811813 TResult ,
812- R1 ,
813- R2 ,
814- R3 ,
815- R4 ,
816- R5 ,
817- R6 ,
818- R7 ,
819- RestFunctions extends Array < ( ...args : TArgs ) => any > ,
814+ FunctionsList extends ReadonlyArray < Fn > &
815+ IfFunctionsArgumentsDoNotOverlap < _Fns , 'Functions arguments types must overlap' > ,
816+ _Fns extends ReadonlyArray < Fn > = FunctionsList ,
820817> (
821- converging : ( ...args : [ R1 , R2 , R3 , R4 , R5 , R6 , R7 , ...ReturnTypesOfFns < RestFunctions > ] ) => TResult ,
822- branches : [
823- ( ...args : TArgs ) => R1 ,
824- ( ...args : TArgs ) => R2 ,
825- ( ...args : TArgs ) => R3 ,
826- ( ...args : TArgs ) => R4 ,
827- ( ...args : TArgs ) => R5 ,
828- ( ...args : TArgs ) => R6 ,
829- ( ...args : TArgs ) => R7 ,
830- ...RestFunctions ,
831- ] ,
832- ) : ( ...args : TArgs ) => TResult ;
833- export function converge < TArgs extends any [ ] , TResult , R1 , R2 , R3 , R4 , R5 , R6 , R7 > (
834- converging : ( ...args : [ R1 , R2 , R3 , R4 , R5 , R6 , R7 ] & { length : 7 } ) => TResult ,
835- branches : [
836- ( ...args : TArgs ) => R1 ,
837- ( ...args : TArgs ) => R2 ,
838- ( ...args : TArgs ) => R3 ,
839- ( ...args : TArgs ) => R4 ,
840- ( ...args : TArgs ) => R5 ,
841- ( ...args : TArgs ) => R6 ,
842- ( ...args : TArgs ) => R7 ,
843- ] ,
844- ) : ( ...args : TArgs ) => TResult ;
845- export function converge < TArgs extends any [ ] , TResult , R1 , R2 , R3 , R4 , R5 , R6 > (
846- converging : ( ...args : [ R1 , R2 , R3 , R4 , R5 , R6 ] & { length : 6 } ) => TResult ,
847- branches : [
848- ( ...args : TArgs ) => R1 ,
849- ( ...args : TArgs ) => R2 ,
850- ( ...args : TArgs ) => R3 ,
851- ( ...args : TArgs ) => R4 ,
852- ( ...args : TArgs ) => R5 ,
853- ( ...args : TArgs ) => R6 ,
854- ] ,
855- ) : ( ...args : TArgs ) => TResult ;
856- export function converge < TArgs extends any [ ] , TResult , R1 , R2 , R3 , R4 , R5 > (
857- converging : ( ...args : [ R1 , R2 , R3 , R4 , R5 ] & { length : 5 } ) => TResult ,
858- branches : [
859- ( ...args : TArgs ) => R1 ,
860- ( ...args : TArgs ) => R2 ,
861- ( ...args : TArgs ) => R3 ,
862- ( ...args : TArgs ) => R4 ,
863- ( ...args : TArgs ) => R5 ,
864- ] ,
865- ) : ( ...args : TArgs ) => TResult ;
866- export function converge < TArgs extends any [ ] , TResult , R1 , R2 , R3 , R4 > (
867- converging : ( ...args : [ R1 , R2 , R3 , R4 ] & { length : 4 } ) => TResult ,
868- branches : [ ( ...args : TArgs ) => R1 , ( ...args : TArgs ) => R2 , ( ...args : TArgs ) => R3 , ( ...args : TArgs ) => R4 ] ,
869- ) : ( ...args : TArgs ) => TResult ;
870- export function converge < TArgs extends any [ ] , TResult , R1 , R2 , R3 > (
871- converging : ( ...args : [ R1 , R2 , R3 ] & { length : 3 } ) => TResult ,
872- branches : [ ( ...args : TArgs ) => R1 , ( ...args : TArgs ) => R2 , ( ...args : TArgs ) => R3 ] ,
873- ) : ( ...args : TArgs ) => TResult ;
874- export function converge < TArgs extends any [ ] , TResult , R1 , R2 > (
875- converging : ( ...args : [ R1 , R2 ] & { length : 2 } ) => TResult ,
876- branches : [ ( ...args : TArgs ) => R1 , ( ...args : TArgs ) => R2 ] ,
877- ) : ( ...args : TArgs ) => TResult ;
878- export function converge < TArgs extends any [ ] , TResult , R1 > (
879- converging : ( ...args : [ R1 ] & { length : 1 } ) => TResult ,
880- branches : [ ( ...args : TArgs ) => R1 ] ,
881- ) : ( ...args : TArgs ) => TResult ;
818+ converging : ( ...args : ReturnTypesOfFns < FunctionsList > ) => TResult ,
819+ branches : FunctionsList ,
820+ ) : _ . F . Curry < ( ...args : LargestArgumentsList < FunctionsList > ) => TResult > ;
821+ export function converge <
822+ CArgs extends ReadonlyArray < any > ,
823+ TResult ,
824+ FunctionsList extends readonly [
825+ ...{
826+ [ Index in keyof CArgs ] : ( ...args : ReadonlyArray < any > ) => CArgs [ Index ] ;
827+ } ,
828+ ] &
829+ IfFunctionsArgumentsDoNotOverlap < _Fns , 'Functions arguments types must overlap' > ,
830+ _Fns extends ReadonlyArray < Fn > = FunctionsList ,
831+ > (
832+ converging : ( ...args : CArgs ) => TResult ,
833+ branches : FunctionsList ,
834+ ) : _ . F . Curry < ( ...args : LargestArgumentsList < FunctionsList > ) => TResult > ;
882835
883836/**
884837 * Returns the number of items in a given `list` matching the predicate `f`
@@ -1054,9 +1007,7 @@ export function endsWith<T>(subList: readonly T[]): (list: readonly T[]) => bool
10541007 */
10551008export function eqBy < T > ( fn : ( a : T ) => unknown , a : T , b : T ) : boolean ;
10561009export function eqBy < T > ( fn : ( a : T ) => unknown , a : T ) : ( b : T ) => boolean ;
1057- export function eqBy < T > (
1058- fn : ( a : T ) => unknown ,
1059- ) : {
1010+ export function eqBy < T > ( fn : ( a : T ) => unknown ) : {
10601011 ( a : T , b : T ) : boolean ;
10611012 ( a : T ) : ( b : T ) => boolean ;
10621013} ;
0 commit comments