index.d.ts 1018 B

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