match
import { match } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/either.ts";Pattern match on an Either value. Provides a function for handling Left values and a function for handling Right values.
@example
import * as E from "./either.ts";
const result = E.right(42);
const message = E.match(
(error) => `Error: ${error}`,
(value) => `Success: ${value}`
)(result);
// "Success: 42"
const errorResult = E.left("Something went wrong");
const errorMessage = E.match(
(error) => `Error: ${error}`,
(value) => `Success: ${value}`
)(errorResult);
// "Error: Something went wrong"