opendir.d.ts 984 B

123456789101112131415161718192021222324
  1. /// <reference types="node" />
  2. /// <reference types="node" />
  3. import { NoParamCallback } from 'fs';
  4. import { Dir, Dirent, FakeFS } from '../FakeFS';
  5. import { Filename, Path } from '../path';
  6. export type CustomDirOptions = {
  7. onClose?: () => void;
  8. };
  9. export declare class CustomDir<P extends Path> implements Dir<P> {
  10. readonly path: P;
  11. private readonly nextDirent;
  12. private readonly opts;
  13. constructor(path: P, nextDirent: () => Dirent | null, opts?: CustomDirOptions);
  14. closed: boolean;
  15. throwIfClosed(): void;
  16. [Symbol.asyncIterator](): AsyncGenerator<Dirent, void, unknown>;
  17. read(): Promise<Dirent>;
  18. read(cb: (err: NodeJS.ErrnoException | null, dirent: Dirent | null) => void): void;
  19. readSync(): Dirent | null;
  20. close(): Promise<void>;
  21. close(cb: NoParamCallback): void;
  22. closeSync(): void;
  23. }
  24. export declare function opendir<P extends Path>(fakeFs: FakeFS<P>, path: P, entries: Array<Filename>, opts?: CustomDirOptions): CustomDir<P>;