MCPcopy
hub / github.com/gvergnaud/ts-pattern / when

Function when

src/patterns.ts:646–659  ·  view source on GitHub ↗
(
  predicate: predicate
)

Source from the content-addressed store, hash-verified

644 predicate: (input: input) => input is narrowed
645): GuardExcludeP<input, narrowed, excluded>;
646export function when<input, predicate extends (value: input) => unknown>(
647 predicate: predicate
648): GuardP<
649 input,
650 predicate extends (value: any) => value is infer narrowed ? narrowed : never
651> {
652 return {
653 [matcher]: () => ({
654 match: <UnknownInput>(value: UnknownInput | input) => ({
655 matched: Boolean(predicate(value as input)),
656 }),
657 }),
658 };
659}
660
661/**
662 * `P.select()` is a pattern which will always match,

Callers 15

patterns.tsFile · 0.85
startsWithFunction · 0.85
endsWithFunction · 0.85
minLengthFunction · 0.85
lengthFunction · 0.85
maxLengthFunction · 0.85
includesFunction · 0.85
regexFunction · 0.85
betweenFunction · 0.85
ltFunction · 0.85
gtFunction · 0.85
lteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…