UNPKG

tiny-readdir

Version:

A simple promisified recursive readdir function.

43 lines (42 loc) 1.23 kB
type Callback = () => void; type ArrayMaybe<T> = T[] | T; type PromiseMaybe<T> = Promise<T> | T; type Dirent = { isFile: () => boolean; isDirectory: () => boolean; isBlockDevice: () => boolean; isCharacterDevice: () => boolean; isSymbolicLink: () => boolean; isFIFO: () => boolean; isSocket: () => boolean; name: string; path: string; }; type Options = { depth?: number; limit?: number; followSymlinks?: boolean; ignore?: ArrayMaybe<((targetPath: string) => boolean) | RegExp>; signal?: { aborted: boolean; }; onDirents?: (dirents: Dirent[]) => PromiseMaybe<undefined>; }; type ResultDirectory = { directories: string[]; directoriesNames: Set<string>; directoriesNamesToPaths: Record<string, string[]>; files: string[]; filesNames: Set<string>; filesNamesToPaths: Record<string, string[]>; symlinks: string[]; symlinksNames: Set<string>; symlinksNamesToPaths: Record<string, string[]>; }; type ResultDirectories = { [path: string]: ResultDirectory; }; type Result = ResultDirectory & { map: ResultDirectories; }; export type { Callback, PromiseMaybe, Dirent, Options, ResultDirectory, ResultDirectories, Result };