UNPKG

1.02 kBTypeScriptView Raw
1// TypeScript Version: 3.2
2
3/// <reference types="node" lib="esnext" />
4
5import * as fs from 'fs';
6import { Readable } from 'stream';
7
8declare namespace readdir {
9 interface EntryInfo {
10 path: string;
11 fullPath: string;
12 basename: string;
13 stats?: fs.Stats;
14 dirent?: fs.Dirent;
15 }
16
17 interface ReaddirpOptions {
18 root?: string;
19 fileFilter?: string | string[] | ((entry: EntryInfo) => boolean);
20 directoryFilter?: string | string[] | ((entry: EntryInfo) => boolean);
21 type?: 'files' | 'directories' | 'files_directories' | 'all';
22 lstat?: boolean;
23 depth?: number;
24 alwaysStat?: boolean;
25 }
26
27 interface ReaddirpStream extends Readable, AsyncIterable<EntryInfo> {
28 read(): EntryInfo;
29 [Symbol.asyncIterator](): AsyncIterableIterator<EntryInfo>;
30 }
31
32 function promise(
33 root: string,
34 options?: ReaddirpOptions
35 ): Promise<EntryInfo[]>;
36}
37
38declare function readdir(
39 root: string,
40 options?: readdir.ReaddirpOptions
41): readdir.ReaddirpStream;
42
43export = readdir;
44
\No newline at end of file