File size: 1,018 Bytes
d8f0e51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// TypeScript Version: 3.2

/// <reference types="node" lib="esnext" />

import * as fs from 'fs';
import { Readable } from 'stream';

declare namespace readdir {
  interface EntryInfo {
    path: string;
    fullPath: string;
    basename: string;
    stats?: fs.Stats;
    dirent?: fs.Dirent;
  }

  interface ReaddirpOptions {
    root?: string;
    fileFilter?: string | string[] | ((entry: EntryInfo) => boolean);
    directoryFilter?: string | string[] | ((entry: EntryInfo) => boolean);
    type?: 'files' | 'directories' | 'files_directories' | 'all';
    lstat?: boolean;
    depth?: number;
    alwaysStat?: boolean;
  }

  interface ReaddirpStream extends Readable, AsyncIterable<EntryInfo> {
    read(): EntryInfo;
    [Symbol.asyncIterator](): AsyncIterableIterator<EntryInfo>;
  }

  function promise(
    root: string,
    options?: ReaddirpOptions
  ): Promise<EntryInfo[]>;
}

declare function readdir(
  root: string,
  options?: readdir.ReaddirpOptions
): readdir.ReaddirpStream;

export = readdir;