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

x/fun/predicate.ts>and

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

Creates the intersection of two predicates, returning true if both predicates return true.

Examples

Example 1

import { and } from "./predicate.ts";
import { pipe } from "./fn.ts";

const isPositive = (n: number) => n > 0;
const isInteger = (n: number) => Number.isInteger(n);

const isPositiveInteger = pipe(
  isPositive,
  and(isInteger),
);

const result1 = isPositiveInteger(1); // true
const result2 = isPositiveInteger(100); // true
const result3 = isPositiveInteger(-1); // false