2424* @param error - encountered error or null
2525* @param result - `x` or `y`
2626*/
27- type Callback = ( error : Error | null , result : any ) => void ;
27+ type Callback < T > = ( error : Error | null , result : T ) => void ;
2828
2929/**
3030* Predicate callback function.
@@ -61,6 +61,15 @@ type PredicateCallback = PredicateNullary | PredicateUnary | PredicateBinary;
6161*/
6262type Predicate = ( clbk : PredicateCallback ) => void ;
6363
64+ /**
65+ * Determines the relationship between two types `T` and `U`, and returns:
66+ *
67+ * - `T` if `T` is assignable to `U`,
68+ * - `U` if `U` is assignable to `T`,
69+ * - A union of `U | T` as a fallback.
70+ */
71+ type ResultFunction < T , U > = T extends U ? T : U extends T ? U : U | T ;
72+
6473/**
6574* If a predicate function returns a truthy value, returns `x`; otherwise, returns `y`.
6675*
@@ -87,7 +96,7 @@ type Predicate = ( clbk: PredicateCallback ) => void;
8796* }
8897* ifelseAsync( predicate, 1.0, -1.0, done );
8998*/
90- declare function ifelseAsync ( predicate : Predicate , x : any , y : any , done : Callback ) : void ;
99+ declare function ifelseAsync < T , U = T > ( predicate : Predicate , x : T , y : U , done : Callback < ResultFunction < T , U > > ) : void ;
91100
92101
93102// EXPORTS //
0 commit comments