mapRight
mapRight<
E,T>(x,f):EextendsRight<unknown> ?Right<T> :E
Applies a transformation function to the Right value of an Either type, if present.
If the input is a Left, it remains unchanged.
Example
mapRight({ right: 'bar' }, (x) => `${x}${x}`)// => { right: "barbar" }
mapRight({ left: 'bar' }, (x) => `${x}${x}`)// => { left: "bar" }Type Parameters
• E extends Either<unknown, unknown>
The type of the Either.
• T
The type of the transformed Right value.
Parameters
x
E
The Either value to map.
f
(r) => T
The transformation function to apply to the Right value.
Returns
E extends Right<unknown> ? Right<T> : E
An Either object where the Right has been transformed if present, or the original Left.