Skip to content

intersects

intersects(a, b, opts?): boolean

Do two segment-patterns share a common matching path? The load-bearing primitive: every other question in the library is a shape over it.

ParameterTypeDescription
aSegmentPatternThe first segment-pattern.
bSegmentPatternThe second segment-pattern.
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 two literal segment arrays intersect only when equal. Subtrees are opted into with **.

intersects(["src", "**", "*.vue"], ["src", "siteA", "components", "Button.vue"]); // true
intersects(["src", "api", "**"], ["src", "web", "**"]); // false