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/either.md.

either

Returns a predicate that checks if a value satisfies either predicate.

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

const isNilOrEmpty = either(isNil, (s: string) => s === '')
isNilOrEmpty(null)

Usage

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

Returns a predicate that checks if a value satisfies either predicate.

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

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

const isNilOrEmpty = either(isNil, (s: string) => s === '')
isNilOrEmpty(null)

Parameters

f(value: T) => booleanrequired

the first predicate.

g(value: T) => booleanrequired

the second predicate.

Returns

a predicate that returns true when either predicate passes.

(value: T) => boolean