<< All versions

Skill v1.0.0

currentLLM-judged scan90/100
senrecep/tsentials/tsentials-predicate
──Details
PublishedOctober 16, 2026 at 06:22 PM
Content Hashsha256:666d466641b0dfed...
Git SHA67da40873698
──Files
Files (1 file, 1.2 KB)
SKILL.md1.2 KBactive
SKILL.md · 42 lines · 1.2 KB

version: "1.0.0"


tsentials/predicate — Skill

Use when you need composable, reusable boolean conditions.

API

typescript
import { Predicate } from 'tsentials/predicate';
import type { Refinement } from 'tsentials/predicate';
// Create predicates
const isAdult = Predicate.from((u: User) => u.age >= 18);
const isActive = Predicate.from((u: User) => u.isActive);
// Combine with logic operators
Predicate.and(isAdult, isActive);
Predicate.or(isAdult, isGuest);
Predicate.not(isAdult);
// Combine many
Predicate.all(isAdult, isActive, hasBalance);
Predicate.any(isAdmin, isModerator);
// Refinement (type guard)
const isString = Predicate.refinement((x: unknown): x is string => typeof x === 'string');
const isNumber = Predicate.refinement((x: unknown): x is number => typeof x === 'number');
// Combine refinements (narrows to intersection)
const isStringAndNumber = Predicate.andRefinement(isString, isNumber); // Refinement<unknown, string & number>
// Convert predicate to a Rule-compatible function
Predicate.toRule(isAdult, validationError); // (value) => error | undefined

Patterns

  • Use Predicate.and / Predicate.or instead of inline && / || for reusable conditions.
  • Convert a Predicate to a Rule with Predicate.toRule.
All versions