Memory file system that instead of writing to disk writes to memory and stores them in a JSON object.

Hierarchy

Constructors

Properties

innerFs: __module = fs

Accessors

Methods

  • Append data to an existing file to the file system, when the directory does not exists it will be created.

    Parameters

    • path: string

      path to the file to read

    • body: string | Buffer

      body to write to the file

    • Optional options: OutputOptions

      write options

    Returns Promise<void>

  • Find files and or folders matching the specified glob pattern as an async iterable. If the result is not iterated completely, the search is stopped. When you need the results as an array, use the Iterable.spreadAsync method to convert the async interable into an array.

    By default the current working directory is used as the base directory for the search.

    You can specify multiple glob patterns to match by specifying an array of glob patterns.

    When a limit is specified, the search is stopped after the specified number of results is reached.

    When a depth is specified, the search does not go deeper than the specified depth.

    Parameters

    • globPatterns: GlobPatterns

      Glob patterns to match

    • Optional options: FindOptions

      find options

    Returns AsyncGenerator<string, any, unknown>

    Async iterable of matching files and or folders

    Example

    for await (const file of fs.find('*.ts')) {
    console.log(file);
    }
  • Returns true if the path exists and is a file, returns false when the path does not exists or is not a file.

    Parameters

    • path: string

      Path to check

    Returns Promise<boolean>

  • Write a file to the file system, when the directory does not exists it will be created.

    Parameters

    • path: string

      path to the file to read

    • Optional body: string | Buffer

      body to write to the file

    • Optional options: OutputOptions

      write options

    Returns Promise<void>

  • Write a file to the file system, when the directory does not exists it will be created.

    Parameters

    • path: string

      path to the file to read

    • Optional data: string | Buffer

      data to write to the file

    • Optional options: WriteOptions

      write options

    Returns Promise<void>