The predicate to filter a value of opt
.
The filtered optional.
import { filter, some, none } from "./option.ts";
import { assertEquals } from "../deps.ts";
const isEven = filter((x: number) => x % 2 == 0);
assertEquals(isEven(none()), none());
assertEquals(isEven(some(3)), none());
assertEquals(isEven(some(4)), some(4));
Generated using TypeDoc
Returns
Some
only ifopt
is aSome
and its value satisfiespredicate
, otherwise returnsNone
.