CombinatorsmapLeftmapLeft CallablemapLeft<E, T>(x: E, f: (l: E extends Left<L> ? L : never) => T): E extends Left<unknown> ? Left<T> : EIf 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. ExamplemapLeft({ left: 'bar' }, (x) => `${x}${x}`)// => { left: "barbar" }mapLeft({ right: 'bar' }, (x) => `${x}${x}`)// => { right: "bar" }Type parametersE: Either<unknown, unknown>TThe mapped type.Parametersx: EThe either value to map.f: (l: E extends Left<L> ? L : never) => TThe map function.Returns E extends Left<unknown> ? Left<T> : EThe mapped either object.
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