Skip to content

witness

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

An example common path (the reachability witness), or null when disjoint. Turns “these overlap” into “these overlap at X”. The witness is free — it is the path the engine already walked to prove intersects.

ParameterTypeDescription
aSegmentPatternThe first segment-pattern.
bSegmentPatternThe second segment-pattern.
opts?OptionsMatching semantics (Options); defaults apply when omitted.

SegmentPattern | null

A SegmentPattern both a and b match, or null if none exists.

A segment of the witness may be the empty string — legal here, since this layer answers in segment vectors. The path API’s witness stringifies, and skips a vector whose LAST segment is empty: parse normalizes a trailing separator back off, so no path string spells it.

witness(["src", "api", "**"], ["src", "**", "handler.ts"]); // ["src", "api", "handler.ts"]
witness(["src", "api", "**"], ["src", "web", "**"]); // null