Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Feb 25, 2024
1 parent f4b4e83 commit bda31f5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions async/if-else/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @param error - encountered error or null
* @param result - `x` or `y`
*/
type Callback = ( error: Error | null, result: any ) => void;
type Callback<T> = ( error: Error | null, result: T ) => void;

/**
* Predicate callback function.
Expand Down Expand Up @@ -61,6 +61,15 @@ type PredicateCallback = PredicateNullary | PredicateUnary | PredicateBinary;
*/
type Predicate = ( clbk: PredicateCallback ) => void;

/**
* Determines the relationship between two types `T` and `U`, and returns:
*
* - `T` if `T` is assignable to `U`,
* - `U` if `U` is assignable to `T`,
* - A union of `U | T` as a fallback.
*/
type ResultFunction<T, U> = T extends U ? T : U extends T ? U : U | T;

/**
* If a predicate function returns a truthy value, returns `x`; otherwise, returns `y`.
*
Expand All @@ -87,7 +96,7 @@ type Predicate = ( clbk: PredicateCallback ) => void;
* }
* ifelseAsync( predicate, 1.0, -1.0, done );
*/
declare function ifelseAsync( predicate: Predicate, x: any, y: any, done: Callback ): void;
declare function ifelseAsync<T, U = T>( predicate: Predicate, x: T, y: U, done: Callback<ResultFunction<T, U>> ): void;


// EXPORTS //
Expand Down

0 comments on commit bda31f5

Please sign in to comment.