guoyujie
9 天以前 a6c698f7418c1b0ea6202f068993d74a3347b0e6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import type { Stats, Dirent } from 'fs';
import { Readable } from 'stream';
export type Path = string;
export interface EntryInfo {
    path: string;
    fullPath: string;
    stats?: Stats;
    dirent?: Dirent;
    basename: string;
}
export type PathOrDirent = Dirent | Path;
export type Tester = (path: EntryInfo) => boolean;
export type Predicate = string[] | string | Tester;
declare function defaultOptions(): {
    root: string;
    fileFilter: (_path: EntryInfo) => boolean;
    directoryFilter: (_path: EntryInfo) => boolean;
    type: string;
    lstat: boolean;
    depth: number;
    alwaysStat: boolean;
    highWaterMark: number;
};
export type ReaddirpOptions = ReturnType<typeof defaultOptions>;
export interface DirEntry {
    files: PathOrDirent[];
    depth: number;
    path: Path;
}
export declare class ReaddirpStream extends Readable {
    parents: any[];
    reading: boolean;
    parent?: DirEntry;
    _stat: Function;
    _maxDepth: number;
    _wantsDir: boolean;
    _wantsFile: boolean;
    _wantsEverything: boolean;
    _root: Path;
    _isDirent: boolean;
    _statsProp: 'dirent' | 'stats';
    _rdOptions: {
        encoding: 'utf8';
        withFileTypes: boolean;
    };
    _fileFilter: Tester;
    _directoryFilter: Tester;
    constructor(options?: Partial<ReaddirpOptions>);
    _read(batch: number): Promise<void>;
    _exploreDir(path: Path, depth: number): Promise<{
        files: string[] | undefined;
        depth: number;
        path: string;
    }>;
    _formatEntry(dirent: PathOrDirent, path: Path): Promise<EntryInfo | undefined>;
    _onError(err: Error): void;
    _getEntryType(entry: EntryInfo): Promise<void | "" | "file" | "directory">;
    _includeAsFile(entry: EntryInfo): boolean | undefined;
}
/**
 * Main function which ends up calling readdirRec and reads all files and directories in given root recursively.
 * @param root Root directory
 * @param options Options to specify root (start directory), filters and recursion depth
 */
export declare const readdirp: (root: Path, options?: Partial<ReaddirpOptions>) => ReaddirpStream;
export declare const readdirpPromise: (root: Path, options?: Partial<ReaddirpOptions>) => Promise<string[]>;
export default readdirp;