Higher order function returning a function that performs the andThen
method on the provided Option.
The returned function chains a new Option to the current one if it is Some.
Creates a new Option from a nullable, potentially-undefined value.
Checks if a value is an Option jonad.
Higher order function returning a function that performs the isNone
method on the provided Option.
The returned function checks if the value is None.
Higher order function returning a function that performs the isSome
method on the provided Option.
The returned function checks if the value is Some.
Higher order function returning a function that performs the map
method on the provided Option.
The returned function maps the value if it is Some.
Creates a new Option with the right-value None
.
Higher order function returning a function that performs the okOr
method on the provided Option.
The returned function maps the Option to a Result.
Higher order function returning a function that performs the okOrError
method on the provided Option.
The returned function maps the Option to a Result, creating a new error from the message if the Option is None.
Transposes an Option of a Result into a Result of an Option.
const option = Option.some("123"); // Some("123")
const option_result = option.map(n => parseIntThrowingError(n)); // Some(Ok(123))
const result_option = Option.transpose(option_result); // Ok(Some(123))
// ...or when there's an error...
const option = Option.some("a"); // Some("a")
const option_result = option.map(n => parseIntThrowingError(n)); // Some(Err(ParseIntError))
const result_option = Option.transpose(option_result); // Err(ParseIntError)
Higher order function returning a function that performs the valueOr
method on the provided Option.
The returned function returns the value if it is Some, otherwise returns a default value.
Option-related utilities.