import { refinement } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { undefinable } = refinement;
Turn a Refinement<A, B>
into Refinement<undefined | A, undefined | B>
.
Examples
Example 1
Example 1
import * as R from "./refinement.ts";
const test = R.undefinable(R.number);
const result1 = test(null); // false
const result2 = test(1); // true, variable is now undefined | number
const result3 = test("hello"); // false
const result4 = test(undefined); // true, variable is now undefined | number
Type Parameters
B extends A
Parameters
or: Refinement<A, B>
Returns
Refinement<A | undefined, B | undefined>