Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
supermacro committed Oct 22, 2023
1 parent ca785d8 commit 1fd6a05
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ For asynchronous tasks, `neverthrow` offers a `ResultAsync` class which wraps a
- [`Result.fromThrowable` (static class method)](#resultfromthrowable-static-class-method)
- [`Result.combine` (static class method)](#resultcombine-static-class-method)
- [`Result.combineWithAllErrors` (static class method)](#resultcombinewithallerrors-static-class-method)
- [`Result.safeUnwrap()`](#resultsafeunwrap)
+ [Asynchronous API (`ResultAsync`)](#asynchronous-api-resultasync)
- [`okAsync`](#okasync)
- [`errAsync`](#errasync)
Expand All @@ -54,10 +55,12 @@ For asynchronous tasks, `neverthrow` offers a `ResultAsync` class which wraps a
- [`ResultAsync.match` (method)](#resultasyncmatch-method)
- [`ResultAsync.combine` (static class method)](#resultasynccombine-static-class-method)
- [`ResultAsync.combineWithAllErrors` (static class method)](#resultasynccombinewithallerrors-static-class-method)
- [`ResultAsync.safeUnwrap()`](#resultasyncsafeunwrap)
+ [Utilities](#utilities)
- [`fromThrowable`](#fromthrowable)
- [`fromPromise`](#frompromise)
- [`fromSafePromise`](#fromsafepromise)
- [`safeTry`](#safetry)
+ [Testing](#testing)
* [A note on the Package Name](#a-note-on-the-package-name)

Expand Down Expand Up @@ -114,6 +117,7 @@ import {
fromThrowable,
fromPromise,
fromSafePromise,
safeTry,
} from 'neverthrow'
```

Expand Down Expand Up @@ -659,8 +663,17 @@ const result = Result.combineWithAllErrors(resultList)
// result is Err(['boooom!', 'ahhhhh!'])
```

[⬆️ Back to top](#toc)

#### `Result.safeUnwrap()`

**⚠️ You must use `.safeUnwrap` in a generator context with `safeTry`**

Allows for unwrapping a `Result` or returning an `Err` implicitly, thereby reducing boilerplate.


[⬆️ Back to top](#toc)

---

### Asynchronous API (`ResultAsync`)
Expand Down Expand Up @@ -1128,6 +1141,13 @@ const result = ResultAsync.combineWithAllErrors(resultList)
// result is Err(['boooom!', 'ahhhhh!'])
```

#### `ResultAsync.safeUnwrap()`

**⚠️ You must use `.safeUnwrap` in a generator context with `safeTry`**

Allows for unwrapping a `Result` or returning an `Err` implicitly, thereby reducing boilerplate.

[⬆️ Back to top](#toc)

---

Expand All @@ -1154,6 +1174,15 @@ Please find documentation at [ResultAsync.fromSafePromise](#resultasyncfromsafep

[⬆️ Back to top](#toc)


#### `safeTry`

Used to implicityly return errors and reduce boilerplate.

See https://github.com/supermacro/neverthrow/pull/448 and https://github.com/supermacro/neverthrow/issues/444
[⬆️ Back to top](#toc)

---

### Testing
Expand Down

0 comments on commit 1fd6a05

Please sign in to comment.