Private
Readonly
leftPrivate
Readonly
rightRuns the provided function if the left value is populated
Runs the provided function if the right value is populated
Maps the Either<L,R>
object to a simple object of type T
.
Each of the mapping functions must return the same type, so that this Either
object can
be mapped.
Only one of the functions will be called, so no side-effects should be relied upon.
Map the left-value of one type to a different value of another type.
If this object is right-valued, then this doesn't change that, but it does
change the overall type of the Either
object
Map the right-value of one type to a different value of another type.
If this object is leftt-valued, then this doesn't change that, but it does
change the overall type of the Either
object
Much like {@link mapLeft}
, this converts an Either
from one type to another.
The difference here is that the mapping function returns an Either
of its own, rather
than just a left-value. This allows you to chain a series of Either
s together, only operating
if you are getting left-valued Either
s
Much like {@link mapRight}
, this converts an Either
from one type to another.
The difference here is that the mapping function returns an Either
of its own, rather
than just a right-value. This allows you to chain a series of Either
s together, only operating
if you are getting right-valued Either
s
Static
joinStatic
joinStatic
leftStatic
right
The
Either<R,L>
type represents 2 possible values of 2 possible types.A common use case it to use this to represent the outcome of a function that could be an error or a value:
const result: Either<ErrorType, ValueType>
. Convention hasErrorType
as the left-value andValueType
as the right-value.The type will only ever be single-valued, but it will always be single-valued