Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

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"
function match<L, R, B>(onLeft: (left: L) => B, onRight: (right: R) => B): (ta: Either<L, R>) => B;
§
match<L, R, B>(onLeft: (left: L) => B, onRight: (right: R) => B): (ta: Either<L, R>) => B
[src]

§Type Parameters

§Parameters

§
onLeft: (left: L) => B
[src]
§
onRight: (right: R) => B
[src]

§Return Type

§
(ta: Either<L, R>) => B
[src]