intersects
intersects(
a,b,opts?):boolean
Do two pattern-sets share a common matching path? The load-bearing primitive.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
a | Patterns | The first pattern-set (Patterns). |
b | Patterns | The second pattern-set (Patterns). |
opts? | Options | Matching semantics (Options); defaults apply when omitted. |
Returns
Section titled “Returns”boolean
true when some path matches both a and b, else false.
Remarks
Section titled “Remarks”A pattern with no wildcards is an EXACT-path match, so
src/x and src/x/y are disjoint (a child is not the path); opt into a
subtree with a trailing **. Dotfiles are excluded unless { dot: true }.
Example
Section titled “Example”intersects("src/api/**", "src/api/handler.ts"); // true — the file is inside the subtreeintersects("src/api/**", "src/web/**"); // false — disjoint subtrees
// Exact-match rule (no wildcards):intersects("src/siteA/components", "src/siteA/components"); // true (same path)intersects("src/siteA/components", "src/siteA/components/Button.vue"); // false (a child, not the path)
// Dot default:intersects("*", ".env"); // false — dotfiles excluded by defaultintersects("*", ".env", { dot: true }); // true