tiny-readdir-glob
Version:
A simple promisified recursive readdir function, with support for globs.
44 lines (33 loc) • 976 B
text/typescript
/* IMPORT */
import type {Dirent} from 'tiny-readdir';
/* HELPERS */
type ArrayMaybe<T> = T[] | T;
type PromiseMaybe<T> = Promise<T> | T;
/* MAIN */
type Options = {
cwd?: string,
depth?: number,
limit?: number,
followSymlinks?: boolean,
ignore?: ArrayMaybe<(( targetPath: string ) => boolean) | RegExp | string>,
signal?: { aborted: boolean },
onDirents?: ( dirents: Dirent[] ) => PromiseMaybe<undefined>
};
type Result = {
/* MATCHED */
directories: string[],
files: string[],
symlinks: string[],
/* FOUND */
directoriesFound: string[],
filesFound: string[],
symlinksFound: string[],
directoriesFoundNames: Set<string>,
filesFoundNames: Set<string>,
symlinksFoundNames: Set<string>,
directoriesFoundNamesToPaths: Record<string, string[]>,
filesFoundNamesToPaths: Record<string, string[]>,
symlinksFoundNamesToPaths: Record<string, string[]>
};
/* EXPORT */
export type {ArrayMaybe, PromiseMaybe, Dirent, Options, Result};