compile
compile(
patterns,opts?):Matcher
Compile a pattern-set once, then query it many times. Parses each pattern
into a SegmentPattern up front; every method reuses that parsed set.
Amortizes the parse when a fixed scope is tested against many paths/patterns.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
patterns | Patterns | The pattern-set to compile (Patterns). |
opts? | Options | Matching semantics (Options) baked into every query. |
Returns
Section titled “Returns”A Matcher bound to patterns and opts.
Example
Section titled “Example”const scope = compile(["src/api/**", "src/db/**"]);
scope.matches("src/api/user.ts"); // truescope.matches("test/api/user.test.ts"); // falsescope.overlapping(["docs/**", "src/db/pool.ts"]); // ["src/db/pool.ts"]