import { expect } from "https://deno.land/x/result_js@2.0.0/operators/extract.ts";
Returns the contained Ok
value.
Examples
Example 1
Example 1
import { Ok } from "https://deno.land/x/result_js/spec.ts";
import { expect } from "https://deno.land/x/result_js/operators/extract.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
const result = Ok(0);
declare const message: string;
assertEquals(expect(result, message), 0);
Example 2
Example 2
import { Err } from "https://deno.land/x/result_js/spec.ts";
import { expect } from "https://deno.land/x/result_js/mod.ts";
import { assertThrows } from "https://deno.land/std/testing/asserts.ts";
declare const message: string;
assertThrows(() => expect(Err(0), message), Error, message);
Change error constructor:
Example 3
Example 3
import { Err } from "https://deno.land/x/result_js/spec.ts";
import { expect } from "https://deno.land/x/result_js/mod.ts";
import { assertThrows } from "https://deno.land/std/testing/asserts.ts";
declare const message: string;
assertThrows(() => expect(Err(0), message, RangeError), RangeError, message);