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.
true
if the Result
is an Err
and and the error inside of it matches a predicate.
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.
true
if the Result
is an Ok
and and the value inside of it matches a predicate.
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))
.
the Result
if it is Ok
, otherwise returns resultB
.
Arguments passed to or
are eagerly evaluated; if you are passing the result of a function call, it is recommended to use orElse
, which is lazily evaluated.
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.
A function that computes a default value.
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.
the contained Err
error or computes it from a closure.
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.
A function that computes a default value.
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.
the contained Ok
value or computes it from a closure.
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
Static
isStatic
isStatic
Readonly
OkStatic
tryStatic
tryOk
if the fn
returned Promise resolves a value, Err
if the fn
throws or the Promise rejected.
Ok
with the resolved value or Err
with the exception error or the rejected value.
The
Result
type is an immutable representation of either success (Ok
) or failure (Err
).