UNPKG

1.51 kBTypeScriptView Raw
1import { Stats } from 'node:fs';
2import { Matcher } from 'picomatch';
3
4type Encoding = "utf8" | "buffer";
5type Dir = string | Uint8Array;
6type RRDirOpts = {
7 strict?: boolean;
8 stats?: boolean;
9 followSymlinks?: boolean;
10 include?: string[];
11 exclude?: string[];
12 insensitive?: boolean;
13};
14type InternalOpts = {
15 includeMatcher?: Matcher;
16 excludeMatcher?: Matcher;
17 encoding?: Encoding;
18};
19type Entry = {
20 /** The path to the entry, will be relative if `dir` is given relative. If `dir` is a `Uint8Array`, this will be too. Always present. */
21 path: Dir;
22 /** Boolean indicating whether the entry is a directory. `undefined` on error. */
23 directory?: boolean;
24 /** Boolean indicating whether the entry is a symbolic link. `undefined` on error. */
25 symlink?: boolean;
26 /** A [`fs.stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object, present when `options.stats` is set. `undefined` on error. */
27 stats?: Stats;
28 /** Any error encountered while reading this entry. `undefined` on success. */
29 err?: Error;
30};
31export declare function rrdir(dir: Dir, opts?: RRDirOpts, { includeMatcher, excludeMatcher, encoding }?: InternalOpts): AsyncGenerator<Entry>;
32export declare function rrdirAsync(dir: Dir, opts?: RRDirOpts, { includeMatcher, excludeMatcher, encoding }?: InternalOpts): Promise<Entry[]>;
33export declare function rrdirSync(dir: Dir, opts?: RRDirOpts, { includeMatcher, excludeMatcher, encoding }?: InternalOpts): Entry[];
34export {};