mapLeft
If the given Either is a Right, return it, otherwise return a new Left with the result of applying the given function to the Left value.
Example
mapLeft({ left: 'bar' }, (x) => `${x}${x}`)// => { left: "barbar" }
mapLeft({ right: 'bar' }, (x) => `${x}${x}`)// => { right: "bar" }
Type Parameters
• E extends Either
<unknown
, unknown
>
• T
The mapped type.
Parameters
x
E
The either value to map.
f
(l
) => T
The map function.
Returns
E
extends Left
<unknown
> ? Left
<T
> : E
The mapped either object.