Skip to main content
Module

x/fun/refinement.ts>or

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function or
import { or } from "https://deno.land/x/fun@v2.0.0-alpha.12/refinement.ts";

Compose two refinements into a new refinement that returns true if either of the two input refinements return true.

Examples

Example 1

import * as R from "./refinement.ts";
import { pipe } from "./fn.ts";

const number = (u: unknown): u is number => typeof u === "number";
const string = (u: unknown): u is string => typeof u === "string";
const refine = pipe(number, R.or(string));

const result1 = refine("Hello"); // true
const result2 = refine(null); // false

Type Parameters

A
C extends A

Returns

<B extends A>(first: Refinement<A, B>) => Refinement<A, B | C>