| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| import type { Stats, Dirent } from 'node:fs'; |
| import { Readable } from 'node: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 = (entryInfo: EntryInfo) => boolean; |
| export type Predicate = string[] | string | Tester; |
| export declare const EntryTypes: { |
| readonly FILE_TYPE: "files"; |
| readonly DIR_TYPE: "directories"; |
| readonly FILE_DIR_TYPE: "files_directories"; |
| readonly EVERYTHING_TYPE: "all"; |
| }; |
| export type EntryType = (typeof EntryTypes)[keyof typeof EntryTypes]; |
| |
| |
| |
| |
| |
| |
| |
| |
| export type ReaddirpOptions = { |
| root: string; |
| fileFilter?: Predicate; |
| directoryFilter?: Predicate; |
| type?: EntryType; |
| lstat?: boolean; |
| depth?: number; |
| alwaysStat?: boolean; |
| highWaterMark?: number; |
| }; |
| |
| 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; |
| } |
| |
| |
| |
| |
| |
| |
| export declare function readdirp(root: Path, options?: Partial<ReaddirpOptions>): ReaddirpStream; |
| |
| |
| |
| |
| |
| export declare function readdirpPromise(root: Path, options?: Partial<ReaddirpOptions>): Promise<EntryInfo[]>; |
| export default readdirp; |
|
|