Maps a Result<T, E>
to Result<T, F>
by applying a function to a contained Err
value, leaving an Ok
value untouched.
This function can be used to pass through a successful result while handling an error.
Ok
if the Result
is Ok
, otherwise returns Err(fn(error))
.
Transposes a Result(Option)
into Option(Result)
.
Ok(Some(_))
will be mapped to `Some(Ok(_))Err(_)
will be mapped to Some(Err(_))
.Ok(_)
will be mapped to Some(Ok(_))
.the contained Err
error or undefined
otherwise.
Arguments passed to unwrapErrOr
are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrapErrOrElse
, which is lazily evaluated.
default error
the contained Err
error or a provided default.
Arguments passed to unwrapErrOr
are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrapErrOrElse
, which is lazily evaluated.
the contained Ok
value or undefined
otherwise.
default value
the contained Ok
value or a provided default.
Arguments passed to unwrapOr
are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrapOrElse
, which is lazily evaluated.
Static
Readonly
ErrStatic
fromErr
if the value is an Error
.
OK
if the value satisfies the predicate, otherwise Err
Source value
A function that returns true
if the value satisfies the predicate, otherwise false
Optional
thisArg: anyIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined
is used instead.
OK
if the value satisfies the predicate, otherwise Err
Source value
A function that returns true
if the value satisfies the predicate, otherwise false
Optional
thisArg: anyIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined
is used instead.
Static
isStatic
isStatic
Readonly
OkStatic
tryStatic
try
The
Result
type is an immutable representation of either success (Ok
) or failure (Err
).