index.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import Stats from './Stats';
  2. import Dirent from './Dirent';
  3. import { Volume as _Volume, StatWatcher, FSWatcher, IReadStream, IWriteStream, DirectoryJSON } from './volume';
  4. import { constants } from './constants';
  5. import type { FsPromisesApi } from './node/types';
  6. export { DirectoryJSON };
  7. export declare const Volume: typeof _Volume;
  8. export declare const vol: _Volume;
  9. export interface IFs extends _Volume {
  10. constants: typeof constants;
  11. Stats: new (...args: any[]) => Stats;
  12. Dirent: new (...args: any[]) => Dirent;
  13. StatWatcher: new () => StatWatcher;
  14. FSWatcher: new () => FSWatcher;
  15. ReadStream: new (...args: any[]) => IReadStream;
  16. WriteStream: new (...args: any[]) => IWriteStream;
  17. promises: FsPromisesApi;
  18. _toUnixTimestamp: any;
  19. }
  20. export declare function createFsFromVolume(vol: _Volume): IFs;
  21. export declare const fs: IFs;
  22. /**
  23. * Creates a new file system instance.
  24. *
  25. * @param json File system structure expressed as a JSON object.
  26. * Use `null` for empty directories and empty string for empty files.
  27. * @param cwd Current working directory. The JSON structure will be created
  28. * relative to this path.
  29. * @returns A `memfs` file system instance, which is a drop-in replacement for
  30. * the `fs` module.
  31. */
  32. export declare const memfs: (json?: DirectoryJSON, cwd?: string) => IFs;
  33. export type IFsWithVolume = IFs & {
  34. __vol: _Volume;
  35. };