Core features of ts-pattern
maints-pattern provides a typesafe way to express complex branching logic with the following capabilities:
- Data Structure Matching: Match on Objects, Arrays, Tuples, Sets, Maps, and primitives.
- Exhaustiveness Checking: Use
.exhaustive()to enforce that all possible cases are covered. - Validation: Use
isMatchingto validate if data matches a specific pattern. - Expressive Wildcards: Use
P._for catch-all or type-specific wildcards likeP.stringandP.number. - Advanced Logic: Supports predicates (
P.when), unions, intersections, and exclusions (P.not). - Property Selection: Use
P.select()to extract specific values from a matched pattern into the callback argument. - Small Footprint: The library is approximately 2kB.