For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/predicate/both.md.

both

Returns a predicate that checks if a value satisfies both predicates.

Binary AND combinator — shorthand for allPass([f, g]). When both inputs are type guards, the result narrows to the intersection of their target types.

const isPositiveEven = both((n: number) => n > 0, (n: number) => n % 2 === 0)
isPositiveEven(4)

Usage

both<T>(f: (value: T) => boolean, g: (value: T) => boolean)

Returns a predicate that checks if a value satisfies both predicates.

Binary AND combinator — shorthand for allPass([f, g]). When both inputs are type guards, the result narrows to the intersection of their target types.

import { both } from 'massaman'
// or:  import { both } from 'massaman/predicate'

const isPositiveEven = both((n: number) => n > 0, (n: number) => n % 2 === 0)
isPositiveEven(4)

Parameters

f(value: T) => booleanrequired

the first predicate.

g(value: T) => booleanrequired

the second predicate.

Returns

a predicate that returns true only when both predicates pass.

(value: T) => boolean