import { filter } from "https://deno.land/x/optio@1.0.0/operators/transform.ts";
Examples
Example 1
Example 1
import { type Option } from "https://deno.land/x/optio/spec.ts";
import { filter } from "https://deno.land/x/optio/operators/transform.ts";
import { assertType, IsExact } from "https://deno.land/std/testing/types.ts";
declare const isString: (value: unknown) => value is string;
declare const option: Option<string | number>;
const opt = filter(option, isString);
assertType<IsExact<typeof opt, Option<string>>>(true);
Examples
Example 1
Example 1
import { None, Some } from "https://deno.land/x/optio/spec.ts";
import { filter } from "https://deno.land/x/optio/operators/transform.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
declare const isEven: (value: number) => boolean;
assertEquals(filter(Some(0), isEven), Some(0));
assertEquals(filter(Some(1), isEven), None);
assertEquals(filter(None, isEven), None);