1/// <reference types="node" resolution-mode="require"/> 2/** 3 * Single-use utility classes to provide functionality to the {@link Glob} 4 * methods. 5 * 6 * @module 7 */ 8import { Minipass } from 'minipass'; 9import { Path } from 'path-scurry'; 10import { IgnoreLike } from './ignore.js'; 11import { Pattern } from './pattern.js'; 12import { Processor } from './processor.js'; 13export interface GlobWalkerOpts { 14 absolute?: boolean; 15 allowWindowsEscape?: boolean; 16 cwd?: string | URL; 17 dot?: boolean; 18 dotRelative?: boolean; 19 follow?: boolean; 20 ignore?: string | string[] | IgnoreLike; 21 mark?: boolean; 22 matchBase?: boolean; 23 maxDepth?: number; 24 nobrace?: boolean; 25 nocase?: boolean; 26 nodir?: boolean; 27 noext?: boolean; 28 noglobstar?: boolean; 29 platform?: NodeJS.Platform; 30 posix?: boolean; 31 realpath?: boolean; 32 root?: string; 33 stat?: boolean; 34 signal?: AbortSignal; 35 windowsPathsNoEscape?: boolean; 36 withFileTypes?: boolean; 37} 38export type GWOFileTypesTrue = GlobWalkerOpts & { 39 withFileTypes: true; 40}; 41export type GWOFileTypesFalse = GlobWalkerOpts & { 42 withFileTypes: false; 43}; 44export type GWOFileTypesUnset = GlobWalkerOpts & { 45 withFileTypes?: undefined; 46}; 47export type Result<O extends GlobWalkerOpts> = O extends GWOFileTypesTrue ? Path : O extends GWOFileTypesFalse ? string : O extends GWOFileTypesUnset ? string : Path | string; 48export type Matches<O extends GlobWalkerOpts> = O extends GWOFileTypesTrue ? Set<Path> : O extends GWOFileTypesFalse ? Set<string> : O extends GWOFileTypesUnset ? Set<string> : Set<Path | string>; 49export type MatchStream<O extends GlobWalkerOpts> = O extends GWOFileTypesTrue ? Minipass<Path, Path> : O extends GWOFileTypesFalse ? Minipass<string, string> : O extends GWOFileTypesUnset ? Minipass<string, string> : Minipass<Path | string, Path | string>; 50/** 51 * basic walking utilities that all the glob walker types use 52 */ 53export declare abstract class GlobUtil<O extends GlobWalkerOpts = GlobWalkerOpts> { 54 #private; 55 path: Path; 56 patterns: Pattern[]; 57 opts: O; 58 seen: Set<Path>; 59 paused: boolean; 60 aborted: boolean; 61 signal?: AbortSignal; 62 maxDepth: number; 63 constructor(patterns: Pattern[], path: Path, opts: O); 64 pause(): void; 65 resume(): void; 66 onResume(fn: () => any): void; 67 matchCheck(e: Path, ifDir: boolean): Promise<Path | undefined>; 68 matchCheckTest(e: Path | undefined, ifDir: boolean): Path | undefined; 69 matchCheckSync(e: Path, ifDir: boolean): Path | undefined; 70 abstract matchEmit(p: Result<O>): void; 71 abstract matchEmit(p: string | Path): void; 72 matchFinish(e: Path, absolute: boolean): void; 73 match(e: Path, absolute: boolean, ifDir: boolean): Promise<void>; 74 matchSync(e: Path, absolute: boolean, ifDir: boolean): void; 75 walkCB(target: Path, patterns: Pattern[], cb: () => any): void; 76 walkCB2(target: Path, patterns: Pattern[], processor: Processor, cb: () => any): any; 77 walkCB3(target: Path, entries: Path[], processor: Processor, cb: () => any): void; 78 walkCBSync(target: Path, patterns: Pattern[], cb: () => any): void; 79 walkCB2Sync(target: Path, patterns: Pattern[], processor: Processor, cb: () => any): any; 80 walkCB3Sync(target: Path, entries: Path[], processor: Processor, cb: () => any): void; 81} 82export declare class GlobWalker<O extends GlobWalkerOpts = GlobWalkerOpts> extends GlobUtil<O> { 83 matches: O extends GWOFileTypesTrue ? Set<Path> : O extends GWOFileTypesFalse ? Set<string> : O extends GWOFileTypesUnset ? Set<string> : Set<Path | string>; 84 constructor(patterns: Pattern[], path: Path, opts: O); 85 matchEmit(e: Result<O>): void; 86 walk(): Promise<Matches<O>>; 87 walkSync(): Matches<O>; 88} 89export declare class GlobStream<O extends GlobWalkerOpts = GlobWalkerOpts> extends GlobUtil<O> { 90 results: O extends GWOFileTypesTrue ? Minipass<Path, Path> : O extends GWOFileTypesFalse ? Minipass<string, string> : O extends GWOFileTypesUnset ? Minipass<string, string> : Minipass<Path | string, Path | string>; 91 constructor(patterns: Pattern[], path: Path, opts: O); 92 matchEmit(e: Result<O>): void; 93 stream(): MatchStream<O>; 94 streamSync(): MatchStream<O>; 95} 96//# sourceMappingURL=walker.d.ts.map