Skip to content

Commit

Permalink
feat: add async methods
Browse files Browse the repository at this point in the history
  • Loading branch information
yifanwww committed Sep 24, 2023
1 parent f2e0b07 commit 9837119
Show file tree
Hide file tree
Showing 4 changed files with 576 additions and 34 deletions.
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,31 @@ This package doesn't implement Rust-like `Option`. Handling `undefined`/`null` i

The Rust-like `Result` implements the following methods:

| Rust-like `Result` method | Rust `Result` method |
| :------------------------ | :--------------------- |
| isOk | [is_ok] |
| isOkAnd | [is_ok_and] |
| isErr | [is_err] |
| isErrAnd | [is_err_and] |
| ok | [ok] |
| err | [err] |
| map | [map] |
| mapOr | [map_or] |
| mapOrElse | [map_or_else] |
| mapErr | [map_err] |
| expect | [expect] |
| unwrap | [unwrap] |
| expectErr | [expect_err] |
| unwrapErr | [unwrap_err] |
| unwrapOr | [unwrap_or] |
| unwrapOrElse | [unwrap_or_else] |
| unwrapUnchecked | [unwrap_unchecked] |
| unwrapErrUnchecked | [unwrap_err_unchecked] |
| and | [and] |
| andThen | [and_then] |
| or | [or] |
| orElse | [or_else] |
| transpose | [transpose] |
| Rust-like `Result` method | Rust `Result` method |
| :------------------------------- | :--------------------- |
| isOk | [is_ok] |
| isOkAnd / isOkAndAsync | [is_ok_and] |
| isErr | [is_err] |
| isErrAnd / isErrAndAsync | [is_err_and] |
| ok | [ok] |
| err | [err] |
| map / mapAsync | [map] |
| mapOr / mapOrAsync | [map_or] |
| mapOrElse / mapOrElseAsync | [map_or_else] |
| mapErr / mapErrAsync | [map_err] |
| expect | [expect] |
| unwrap | [unwrap] |
| expectErr | [expect_err] |
| unwrapErr | [unwrap_err] |
| unwrapOr | [unwrap_or] |
| unwrapOrElse / unwrapOrElseAsync | [unwrap_or_else] |
| unwrapUnchecked | [unwrap_unchecked] |
| unwrapErrUnchecked | [unwrap_err_unchecked] |
| and | [and] |
| andThen / andThenAsync | [and_then] |
| or | [or] |
| orElse / orElseAsync | [or_else] |
| transpose | [transpose] |

Unlike Rust, JavaScript doesn't have the 'Ownership' feature, so some API like `as_ref` are not necessary. These implementations are not implemented:

Expand Down
Loading

0 comments on commit 9837119

Please sign in to comment.