Skip to content

Intersect

Intersect is a path-pattern overlap engine. It answers one question: do two globs share a common matching path? It reasons over patterns as languages — pure pattern algebra — and never touches the filesystem, except through the opt-in @sksizer/intersect/fs layer. The pairwise question (A vs. B) is polynomial, so the API stays pairwise and one-vs-set.

A pattern with no wildcards is an exact-path match. There is no directory/file inference and no ambiguity error: a bare path is exactly that path, and you opt into a subtree 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");
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

Three subpaths, layered so dependencies point down. The core, the segments engine, and the path API pull zero runtime dependencies; only @sksizer/intersect/fs pulls a globber. The dependency boundary is the entry-point split itself.

ImportLayerWhat it isRuntime deps
@sksizer/intersect/segmentsL0 corePure engine over pre-split segment arrays — no strings, no disk.none
@sksizer/intersectL1 path APIFriendly surface: parses glob strings, set-aware primitives, the registry.none
@sksizer/intersect/fsL2 filesystemAsync resolution against a real on-disk tree.tinyglobby
import { intersects } from "@sksizer/intersect";
intersects("src/**/*.ts", "src/api/handler.ts");
intersects("src/api/**", "src/web/**");
intersects("src/api/**", "src/**/*.ts");
ABResultWhy
src/**/*.tssrc/api/handler.tstruethe file is inside the glob
src/api/**src/web/**falsedisjoint subtrees
src/api/**src/**/*.tstruesrc/api/x.ts is common to both

The API Reference section in the sidebar is generated directly from the TypeScript source of the three entry points, so it always matches the shipped surface. Start with intersects, matches, overlapping, and witness on the path API.