You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1018 B

2 years ago
  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;