Skip to main content
Module

x/fun/mod.ts>predicate.and

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

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