import { optic } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { nil } = optic;
A preconstructed filter that focuses on the the non-null and non-undefined value of A | null | undefined.
Examples
Example 1
Example 1
import * as O from "./optic.ts";
import { constNone } from "./option.ts";
import { pipe } from "./fn.ts";
type Input = { value?: string | null };
const value = pipe(O.id<Input>(), O.prop("value"), O.nil);
const result1 = pipe(value, O.view({})); // None
const result2 = pipe(value, O.view({ value: "Hello" })); // Some("Hello")