Skip to content

Getting started

Intersect ships three import subpaths, layered so dependencies point down. Reach for the one that matches the question you have.

ImportReach for it whenRuntime deps
@sksizer/intersectYou hold glob strings and want the friendly, set-aware surface.none
@sksizer/intersect/segmentsYou already have pre-split segment arrays and want the pure core.none
@sksizer/intersect/fsYou need the concrete files on disk that fall in a scope.tinyglobby

The dependency boundary is the entry-point split itself. The path API and the segment core pull zero runtime dependencies; only @sksizer/intersect/fs — the sole layer that reads disk — pulls a globber. Import it only when you need real files.

import { intersects } from "@sksizer/intersect";
intersects("src/**/*.ts", "src/api/handler.ts");
intersects("src/api/**", "src/web/**");
ABResultWhy
src/**/*.tssrc/api/handler.tstruethe file is inside the glob
src/api/**src/web/**falsedisjoint subtrees

intersects is the load-bearing primitive. Every other question in the library is a shape over it.

An array is the union of its patterns; a single string is a one-element set. The same primitives take whichever shape you already hold, on either argument.

import { intersects } from "@sksizer/intersect";
intersects(["src/api/**", "src/db/**"], "src/db/pool.ts");
intersects(["src/api/**"], ["docs/**", "src/**/*.md"]);
intersects(["a/**"], ["b/**", "c/**"]);
ABResultWhy
["src/api/**", "src/db/**"]"src/db/pool.ts"truematches the 2nd of the set
["src/api/**"]["docs/**", "src/**/*.md"]truesrc/api/x.md is common
["a/**"]["b/**", "c/**"]falseno shared path anywhere

The pairwise question (A vs. B) is polynomial, so the API stays pairwise and one-vs-set — it never asks the intractable many-pattern question. Next: the pattern dialect and the primitives.