Skip to content

Commit

Permalink
docs: add more doc to resultify.promise
Browse files Browse the repository at this point in the history
  • Loading branch information
yifanwww committed Sep 17, 2023
1 parent 887181f commit 950747d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ Takes a promise and returns a new promise that contains a result.
const result = await resultify.promise(promise);
```

Due to the limit of TypeScript,it's impossible to resultify overloaded functions perfectly that the returned functions are still overloaded.
This function allows you to resultify the promise that the overloaded functions return.

## Write Your Own Implementation of `Result`?

Although you do have the ability to do so, it's not recommended that you write your own implementation.
Expand Down
4 changes: 4 additions & 0 deletions src/resultify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ type NoVoid<T> = T extends void ? undefined : T;
* ```ts
* const result = await resultify.promise(promise);
* ```
*
* Due to the limit of TypeScript,it's impossible to resultify overloaded functions perfectly that
* the returned functions are still overloaded.
* This function allows you to resultify the promise that the overloaded functions return.
*/
async function resultifyPromise<T, E>(promise: Promise<T>): Promise<Result<NoVoid<T>, E>> {
try {
Expand Down

0 comments on commit 950747d

Please sign in to comment.