Skip to content

intersects

intersects(a, b, opts?): boolean

Do two pattern-sets share a common matching path? The load-bearing primitive.

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

boolean

true when some path matches both a and b, else false.

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 }.

intersects("src/api/**", "src/api/handler.ts"); // true — the file is inside the subtree
intersects("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 default
intersects("*", ".env", { dot: true }); // true