Skip to content

witness

witness(a, b, opts?): string | null

An example path common to both sets (turns “overlap” into “overlap at X”), or null when disjoint.

ParameterTypeDescription
aPatternsThe first pattern-set (Patterns).
bPatternsThe second pattern-set (Patterns).
opts?OptionsMatching semantics (Options); defaults apply when omitted.

string | null

A concrete path matching both sets, or null if none exists.

The returned string always matches both sets. A segment-vector that no path string can spell — one ending in an empty segment, which only a degenerate pattern such as {,x} produces — is not reported; for such a pair this returns null even though intersects (which answers over segment vectors, not path strings) says true.

witness("src/api/**", "src/api/handler.ts"); // "src/api/handler.ts" — a path both match
witness("src/api/**", "src/web/**"); // null — no common path