| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | // TypeScript Version: 3.2 |
| 2 | |
| 3 | /// <reference types="node" lib="esnext" /> |
| 4 | |
| 5 | import * as fs from 'fs'; |
| 6 | import { Readable } from 'stream'; |
| 7 | |
| 8 | declare 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 | |
| 38 | declare function readdir( |
| 39 | root: string, |
| 40 | options?: readdir.ReaddirpOptions |
| 41 | ): readdir.ReaddirpStream; |
| 42 | |
| 43 | export = readdir; |