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/these.ts";

Pattern match on a These to extract values.

@example
import { match, left, right, both } from "./these.ts";

const matcher = match(
  (error) => `Error: ${error}`,
  (value) => `Success: ${value}`,
  (warning, value) => `Partial: ${warning} - ${value}`
);

console.log(matcher(left("Failed"))); // "Error: Failed"
console.log(matcher(right(42))); // "Success: 42"
console.log(matcher(both("Warning", 42))); // "Partial: Warning - 42"
function match<A, B, O>(
onLeft: (b: B) => O,
onRight: (a: A) => O,
onBoth: (b: B, a: A) => O,
): (ta: These<B, A>) => O;
§
match<A, B, O>(onLeft: (b: B) => O, onRight: (a: A) => O, onBoth: (b: B, a: A) => O): (ta: These<B, A>) => O
[src]

§Type Parameters

§Parameters

§
onLeft: (b: B) => O
[src]
§
onRight: (a: A) => O
[src]
§
onBoth: (b: B, a: A) => O
[src]

§Return Type

§
(ta: These<B, A>) => O
[src]