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/match/isMatching.md.

isMatching ts-pattern

A predicate form of match — returns true/false instead of a value, and narrows types in the truthy branch.

if (isMatching(pattern, value)) { /* value is narrowed */ }

Usage

isMatching(pattern, value)

Use when you want pattern-based narrowing in an if or guard, not a multi-arm dispatch.

import { isMatching, P } from 'massaman/match'

const isClickAt = isMatching({ kind: 'click', x: P.number, y: P.number })

if (isClickAt(event)) {
  // event is { kind: 'click'; x: number; y: number }
  drawAt(event.x, event.y)
}

isMatching(pattern) — partial application

Called with one argument, returns a reusable guard function. Composes well with filter:

import { isMatching, P } from 'massaman'

const clicks = events.filter(isMatching({ kind: 'click' }))
// clicks: Array<{ kind: 'click'; ... }>

See also

Source: ts-pattern

Re-exported unchanged from ts-pattern at the pinned version.