partition
import { partition } from "https://raw.githubusercontent.com/baetheus/fun/main/option.ts";
Given a refinement or predicate, return a function that splits an Option into a Pair<Option, Option>. Due to the nature of the option type this will always return Pair<Some, None>, Pair<None, None>, or Pair<None, Some>.
@example
import * as O from "./option.ts";
const partition = O.partition((n: number) => n > 0);
const result1 = partition(O.some(1)); // [Some(1), None]
const result2 = partition(O.some(0)); // [None, Some(0)]
const result3 = partition(O.none); // [None, None]
function partition<A, B extends A>(refinement: Refinement<A, B>): (ua: Option<A>) => Pair<Option<B>, Option<A>>;
§
partition<A, B extends A>(refinement: Refinement<A, B>): (ua: Option<A>) => Pair<Option<B>, Option<A>>
[src]Given a refinement or predicate, return a function that splits an Option into a Pair<Option, Option>. Due to the nature of the option type this will always return Pair<Some, None>, Pair<None, None>, or Pair<None, Some>.
@example
import * as O from "./option.ts";
const partition = O.partition((n: number) => n > 0);
const result1 = partition(O.some(1)); // [Some(1), None]
const result2 = partition(O.some(0)); // [None, Some(0)]
const result3 = partition(O.none); // [None, None]
§Parameters
§
refinement: Refinement<A, B>
[src]