import { andThen } from "https://deno.land/x/optio@1.0.0/operators/logical.ts";
Returns None
if the option
is None
, otherwise calls fn
with the wrapped value and returns the result.
Examples
Example 1
Example 1
import { None, Some } from "https://deno.land/x/optio/spec.ts";
import { andThen } from "https://deno.land/x/optio/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
declare const square: (value: number) => number;
assertEquals(andThen(Some(3), square), Some(9));
assertEquals(andThen(None, square), None);