index.d.ts 1.5 KB

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