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://raw.githubusercontent.com/baetheus/fun/main/option.ts";

The match functionis the standard catamorphism on an Option. It operates like a switch case operator over the two potential cases for an Option type. One supplies functions for handling the Some case and the None case with matching return types and fold calls the correct function for the given option.

@example
import * as O from "./option.ts";

const toNumber = O.match(() => 0, n => n);

const result1 = toNumber(O.none); // 0
const result2 = toNumber(O.some(1)); // 1
function match<A, B>(onNone: () => B, onSome: (a: A) => B): (ua: Option<A>) => B;
§
match<A, B>(onNone: () => B, onSome: (a: A) => B): (ua: Option<A>) => B
[src]

§Type Parameters

§Parameters

§
onNone: () => B
[src]
§
onSome: (a: A) => B
[src]

§Return Type

§
(ua: Option<A>) => B
[src]