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
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