The path API is a small set of primitives, all shapes over the same pairwise question. Each
coerces its Patterns argument (a string or a set) to segment-patterns, then defers to the
core.
overlapping has two forms that filter opposite sides. The free function returns a
subset of its first argument, query, in query order. A compiled Matcher.overlapping
returns a subset of ITS argument, candidates.
A witness is a concrete path both sets match, or null when they are disjoint. It is free:
the reachability path the engine already walked to prove the overlap. It turns “these
overlap” into “these overlap atX”.
import { witness } from"@sksizer/intersect";
witness("src/api/**", "src/**/handler.ts");
witness("src/api/**", "src/web/**");
A
B
Witness
Why
src/api/**
src/**/handler.ts
"src/api/handler.ts"
a concrete path both match
src/api/**
src/web/**
null
no common path
*/*
*/{,.a}
null
the only common path has no spelling
The last row is the one edge: the witness is always a path that really matches both sides, so a
common path that no string can spell is reported as null. That takes a segment the two sides
share only when it is EMPTY (* will not match .a, so {,.a} is left with its empty branch),
landing at the end of the path — and parse normalizes a trailing separator back off, so "a/"
would come back as ["a"] and match neither side. intersects, which answers over segment vectors
rather than strings, still reports true for such a pair.