Returns an iterator over the possibly contained value.
The iterator yields one value if the result is Some
, otherwise none.
Returns None
if the Option
is None
, otherwise calls predicate with the wrapped value and returns:
Some(t)
if predicate returns true
(where t
is the wrapped value), andNone
if predicate returns false
.A function that returns true
or 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.
Converts from Option<Option<T>>
to Option<T>
true
if the Option
is a None
.
Whether this
value is the same as the other Option
.
Another Option
or any value
true
if the other is an Option
and the value are the same as this
value via Object.is
.
true
if the Option
is a Some
.
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.
true
if the Option
is a Some
and and the value inside of it matches a predicate.
Extract the value from an Option
in a way that handles both the Some
and None
cases.
The value returned by the provided function.
Transforms the Option<T>
into a Result<T, E>
, mapping Some(v)
to Ok(v)
and None to Err(err)
.
Arguments passed to okOr
are eagerly evaluated; if you are passing the result of a function call, it is recommended to use okOrElse
, which is lazily evaluated.
The error value for Err
if the Option
is None
.
Transforms the Option<T>
into a Result<T, E>
, mapping Some(v)
to Ok(v)
and None
to Err(err())
.
A function that returns the error value for Err
if the Option
is None
.
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.
Optional Error message
the contained Some
value.
the contained Some
value or undefined
otherwise.
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
fromWrap a value in an Option
if the value satisfies the predicate.
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
isAn Option
or any value
An Option
or any value
true
if the both are Option
and the value are the same via Object.is
.
Static
SomeStatic
unwrap
The
Option
type is an immutable representation of an optional value: everyOption
is eitherSome
and contains a value, orNone
and does not.