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

Pattern match on a Free structure to extract values.

@example
import { match, node, link } from "./free.ts";

const matcher = match(
  (value) => `Single value: ${value}`,
  (first, second) => `Combined: ${first} and ${second}`
);

const single = node(42);
const combined = link(node(1), node(2));

console.log(matcher(single)); // "Single value: 42"
console.log(matcher(combined)); // "Combined: [object Object] and [object Object]"
function match<A, O>(onNode: (value: A) => O, onLink: (first: Free<A>, second: Free<A>) => O): (ua: Free<A>) => O;
§
match<A, O>(onNode: (value: A) => O, onLink: (first: Free<A>, second: Free<A>) => O): (ua: Free<A>) => O
[src]

§Type Parameters

§Parameters

§
onNode: (value: A) => O
[src]
§
onLink: (first: Free<A>, second: Free<A>) => O
[src]

§Return Type

§
(ua: Free<A>) => O
[src]