import { option } from "https://deno.land/x/fun@v2.0.0-alpha.12/mod.ts";
const { filterMap } = option;
Apply a filter and mapping operation at the same time against an Option. This is equivalent to the flatmap function for Option.
Examples
Example 1
Example 1
import * as O from "./option.ts";
const noninit = (str: string) => str.length > 0 ? O.some(str.length) : O.none;
const filterMap = O.filterMap(noninit);
const result1 = filterMap(O.some("Hello")); // Some(5);
const result2 = filterMap(O.some("")); // None
const result3 = filterMap(O.none); // None