index.d.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { Stats, Dirent, Volume, StatWatcher, FSWatcher } from '@jsonjoy.com/fs-node';
  2. import type { IWriteStream } from '@jsonjoy.com/fs-node';
  3. import { DirectoryJSON, NestedDirectoryJSON } from '@jsonjoy.com/fs-core';
  4. import { constants } from '@jsonjoy.com/fs-node-utils';
  5. import type { FsPromisesApi } from '@jsonjoy.com/fs-node-utils';
  6. import type * as misc from '@jsonjoy.com/fs-node-utils/lib/types/misc';
  7. export { DirectoryJSON, NestedDirectoryJSON, 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[]) => misc.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?: NestedDirectoryJSON, cwd?: string) => {
  33. fs: IFs;
  34. vol: Volume;
  35. };
  36. export type IFsWithVolume = IFs & {
  37. __vol: Volume;
  38. };