Skip to content

Update README to not require safeUnwrap after 8.0.0 #599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ const result = Result.combineWithAllErrors(resultList)

#### `Result.safeUnwrap()`

**⚠️ You must use `.safeUnwrap` in a generator context with `safeTry`**. Please see [safeTry](#safeTry).
**⚠️ If you are using version 8.0.0 or earlier, you must use `.safeUnwrap` in a generator context with `safeTry`**. Please see [safeTry](#safeTry).

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

Expand Down Expand Up @@ -1412,7 +1412,7 @@ const result = ResultAsync.combineWithAllErrors(resultList)

#### `ResultAsync.safeUnwrap()`

**⚠️ You must use `.safeUnwrap` in a generator context with `safeTry`**. Please see [safeTry](#safeTry).
**⚠️ If you are using version 8.0.0 or earlier, you must use `.safeUnwrap` in a generator context with `safeTry`**. Please see [safeTry](#safeTry).

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

Expand Down Expand Up @@ -1493,12 +1493,12 @@ function myFunc(): Result<number, string> {
// Otherwise, this `(yield* ...)` is evaluated to its `.value`.
(yield* mayFail1()
.mapErr(e => `aborted by an error from 1st function, ${e}`)
.safeUnwrap())
// .safeUnwrap()) ⚠️ You must use this for version 8.0.0 or earlier
+
// The same as above.
(yield* mayFail2()
.mapErr(e => `aborted by an error from 2nd function, ${e}`)
.safeUnwrap())
// .safeUnwrap()) ⚠️ You must use this for version 8.0.0 or earlier
)
})
}
Expand All @@ -1521,12 +1521,12 @@ function myFunc(): Promise<Result<number, string>> {
// You have to await if the expression is Promise<Result>
(yield* (await mayFail1())
.mapErr(e => `aborted by an error from 1st function, ${e}`)
.safeUnwrap())
// .safeUnwrap()) ⚠️ You must use this for version 8.0.0 or earlier
+
// You can call `safeUnwrap` directly if its ResultAsync
(yield* mayFail2()
.mapErr(e => `aborted by an error from 2nd function, ${e}`)
.safeUnwrap())
// .safeUnwrap()) ⚠️ You must use this for version 8.0.0 or earlier
)
})
}
Expand Down