mapLefts
mapLefts<
Xs
,T
>(xs
,f
):ArgLefts
<Xs
> extendsnever
[] ?Right
<ArgRights
<Xs
>[number
]> :ArgRights
<Xs
>[number
] extendsnever
[] ?Left
<T
> :Left
<T
> |Right
<ArgRights
<Xs
>[number
]>
mapLefts
takes a tuple of Either
s and a function that takes the left values of the Either
s and
returns a new Either
with the left value being the result of the function and the right value
being the right value of the first Either
in the tuple.
Example
mapLefts([{ left: 'foo' }, { left: 'bar' }], ([x0, x1]) => `${x0}${x1}`)// => { left: "foobar" }
mapLefts([{ right: 'bar' }, { left: 'fooz' }], ([x0, x1]) => `${x0}${x1}`)// => { right: "bar" }
Type Parameters
• Xs extends Either
<unknown
, unknown
>[]
• T
The mapped type.
Parameters
xs
readonly [Xs
]
The either values to map.
f
(ls
) => T
The map function.
Returns
ArgLefts
<Xs
> extends never
[] ? Right
<ArgRights
<Xs
>[number
]> : ArgRights
<Xs
>[number
] extends never
[] ? Left
<T
> : Left
<T
> | Right
<ArgRights
<Xs
>[number
]>
The mapped either object.