import { andThen } from "https://deno.land/x/result_js@2.0.0/operators/logical.ts";
Calls fn
if the result
is Ok
, otherwise returns the Err
.
Examples
Example 1
Example 1
import { andThen } from "https://deno.land/x/result_js/operators/logical.ts";
import { Err, Ok } from "https://deno.land/x/result_js/spec.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
declare const square: (value: number) => Ok<number>;
assertEquals(andThen(Ok(3), square), Ok(9));
assertEquals(andThen(Err(1), square), Err(1));