Predicate
Predicate:
object
Defined in: Core/Predicate.ts:29
Type Declaration
Section titled “Type Declaration”all: <
A>(predicates) =>Predicate<A>
Combines an array of predicates with AND: passes only when every predicate holds.
Returns true for an empty array (vacuous truth).
Type Parameters
Section titled “Type Parameters”A
Parameters
Section titled “Parameters”predicates
Section titled “predicates”readonly Predicate<A>[]
Returns
Section titled “Returns”Predicate<A>
Example
Section titled “Example”and: <
A>(second) => (first) =>Predicate<A>
Combines two predicates with logical AND: passes only when both hold.
Data-last — the first predicate is the data being piped.
Type Parameters
Section titled “Type Parameters”A
Parameters
Section titled “Parameters”second
Section titled “second”Predicate<A>
Returns
Section titled “Returns”(first) => Predicate<A>
Example
Section titled “Example”any: <
A>(predicates) =>Predicate<A>
Combines an array of predicates with OR: passes when at least one holds.
Returns false for an empty array.
Type Parameters
Section titled “Type Parameters”A
Parameters
Section titled “Parameters”predicates
Section titled “predicates”readonly Predicate<A>[]
Returns
Section titled “Returns”Predicate<A>
Example
Section titled “Example”from:
object
from.Refinement
Section titled “from.Refinement”Refinement: <
A,B>(r) =>Predicate<A> =fromRefinement
Converts a Refinement<A, B> into a Predicate<A>, discarding the compile-time
narrowing. Use this when you want to combine a type guard with plain predicates
using and, or, or all.
This is a zero-cost runtime type cast.
Type Parameters
Section titled “Type Parameters”A
B
Parameters
Section titled “Parameters”Refinement<A, B>
Returns
Section titled “Returns”Predicate<A>
Example
Section titled “Example”match: <
A,B>(branches,fallback) => (a) =>B
Performs declarative conditional branching over [predicate, handler] pairs,
returning the handler result of the first matching predicate or evaluating the fallback.
Type Parameters
Section titled “Type Parameters”A
B
Parameters
Section titled “Parameters”branches
Section titled “branches”readonly readonly [Predicate<A>, (a) => B][]
fallback
Section titled “fallback”(a) => B
Returns
Section titled “Returns”(a) => B
Example
Section titled “Example”not: <
A>(p) =>Predicate<A>
Negates a predicate: the result passes exactly when the original fails.
Type Parameters
Section titled “Type Parameters”A
Parameters
Section titled “Parameters”Predicate<A>
Returns
Section titled “Returns”Predicate<A>
Example
Section titled “Example”or: <
A>(second) => (first) =>Predicate<A>
Combines two predicates with logical OR: passes when either holds.
Data-last — the first predicate is the data being piped.
Type Parameters
Section titled “Type Parameters”A
Parameters
Section titled “Parameters”second
Section titled “second”Predicate<A>
Returns
Section titled “Returns”(first) => Predicate<A>
Example
Section titled “Example”using: <
A,B>(f) => (p) =>Predicate<B>
Adapts a Predicate<A> to work on a different input type B by applying f
to extract the relevant A from a B before running the check.
Data-last — the predicate is the data being piped; f is the extractor.
Type Parameters
Section titled “Type Parameters”A
B
Parameters
Section titled “Parameters”(b) => A
Returns
Section titled “Returns”(p) => Predicate<B>