Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/mod.ts>predicate.or

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

Creates the union of two predicates, returning true if either predicate returns true.

Examples

Example 1

import { or } from "./predicate.ts";
import { string, number } from "./refinement.ts";
import { pipe } from "./fn.ts";

// A Refinement is also a Predicate
const stringOrNumber = pipe(
  string,
  or(number),
);

const result1 = stringOrNumber("Hello"); // true
const result2 = stringOrNumber(1); // true
const result3 = stringOrNumber({}); // false