Skip to content

Patterns

Intersect reasons over patterns as languages, not over the filesystem. parse splits a path-like string on / and takes each segment as a glob token, verbatim. There is no inference — no directory/file heuristic, no ambiguity error. A single trailing separator is normalized off, so src/api/ equals src/api; nothing else is collapsed.

A pattern with no wildcards is an exact-path match. A bare path is exactly that path, not the files beneath it. You opt into a subtree explicitly with /**.

import { intersects } from "@sksizer/intersect";
// No wildcards → an exact-path match. Opt into a subtree explicitly with `**`.
intersects("src/siteA/components", "src/siteA/components");
intersects("src/siteA/components", "src/siteA/components/Button.vue");
intersects("src/siteA/components/**", "src/siteA/components/Button.vue");
intersects("**/*.vue", "src/siteA/components/Button.vue");
ABResultWhy
src/siteA/componentssrc/siteA/componentstruesame path
src/siteA/componentssrc/siteA/components/Button.vuefalsea child, not the path
src/siteA/components/**src/siteA/components/Button.vuetrueexplicit ** subtree
**/*.vuesrc/siteA/components/Button.vuetruewildcards work as usual

Each segment between separators is a glob token. / is a distinguished symbol that the per-segment wildcards never cross.

TokenMatches
*any run of characters within one segment ([^/]*)
?exactly one character within a segment
**zero or more whole segments — the only token that crosses /
{a,b}alternation: a or b (e.g. *.{vue,html,jsx})
[abc], [a-z]one character from the class
[!abc]one character NOT in the class
literal textitself, verbatim

Matching semantics are shared by the segment core and the path API. All default off except globstarMatchesZero.

OptionDefaultEffect
caseInsensitivefalseMatch paths ignoring ASCII case.
dotfalseLet */** match a leading-dot segment. Off, so dotfiles are excluded.
globstarMatchesZerotrueLet a globstar span zero segments, so a/**/b matches a/b.
import { intersects } from "@sksizer/intersect";
intersects("SRC/**", "src/api.ts", { caseInsensitive: true });
intersects("*", ".env");
intersects("*", ".env", { dot: true });
intersects("a/**/b", "a/b", { globstarMatchesZero: true });
ABOptionsResultWhy
SRC/**src/api.ts{ caseInsensitive: true }trueASCII case ignored
*.envfalsedotfiles excluded by default
*.env{ dot: true }truedot opt-in
a/**/ba/b{ globstarMatchesZero: true }trueglobstar spans zero segments

Pattern-level negation (!pat, gitignore re-includes) is out of v1 — it needs language complement. Class-negation [!abc] is fine, since it is per-character, not per-pattern.