UNPKG

2.14 kBTypeScriptView Raw
1import { MMRegExp } from 'minimatch';
2import { Path } from 'path-scurry';
3import { Pattern } from './pattern.js';
4import { GlobWalkerOpts } from './walker.js';
5/**
6 * A cache of which patterns have been processed for a given Path
7 */
8export declare class HasWalkedCache {
9 store: Map<string, Set<string>>;
10 constructor(store?: Map<string, Set<string>>);
11 copy(): HasWalkedCache;
12 hasWalked(target: Path, pattern: Pattern): boolean | undefined;
13 storeWalked(target: Path, pattern: Pattern): void;
14}
15/**
16 * A record of which paths have been matched in a given walk step,
17 * and whether they only are considered a match if they are a directory,
18 * and whether their absolute or relative path should be returned.
19 */
20export declare class MatchRecord {
21 store: Map<Path, number>;
22 add(target: Path, absolute: boolean, ifDir: boolean): void;
23 entries(): [Path, boolean, boolean][];
24}
25/**
26 * A collection of patterns that must be processed in a subsequent step
27 * for a given path.
28 */
29export declare class SubWalks {
30 store: Map<Path, Pattern[]>;
31 add(target: Path, pattern: Pattern): void;
32 get(target: Path): Pattern[];
33 entries(): [Path, Pattern[]][];
34 keys(): Path[];
35}
36/**
37 * The class that processes patterns for a given path.
38 *
39 * Handles child entry filtering, and determining whether a path's
40 * directory contents must be read.
41 */
42export declare class Processor {
43 hasWalkedCache: HasWalkedCache;
44 matches: MatchRecord;
45 subwalks: SubWalks;
46 patterns?: Pattern[];
47 follow: boolean;
48 dot: boolean;
49 opts: GlobWalkerOpts;
50 constructor(opts: GlobWalkerOpts, hasWalkedCache?: HasWalkedCache);
51 processPatterns(target: Path, patterns: Pattern[]): this;
52 subwalkTargets(): Path[];
53 child(): Processor;
54 filterEntries(parent: Path, entries: Path[]): Processor;
55 testGlobstar(e: Path, pattern: Pattern, rest: Pattern | null, absolute: boolean): void;
56 testRegExp(e: Path, p: MMRegExp, rest: Pattern | null, absolute: boolean): void;
57 testString(e: Path, p: string, rest: Pattern | null, absolute: boolean): void;
58}
59//# sourceMappingURL=processor.d.ts.map
\No newline at end of file