data-test-api
    Preparing search index...

    Class DataTestApi<RootPath>

    Type Parameters

    • RootPath extends Path<string>
    Index

    Constructors

    • Create a new instance of DataTestApi.

      Type Parameters

      • RootPath extends string

      Parameters

      • root: RootPath

        The root directory for the data test API. It can be relative or absolute.

      • Optionalfilter: (file: Dirent) => boolean

        An optional filter function to determine which files to include. Defaults to filtering only files. /!\ If you provide a filter and want to get only files, yuo must specify it in your filter.

      Returns DataTestApi<RootPath>

    Accessors

    Methods

    • Get an async iterator of FileEntry objects for all files (recursive) in the root directory matching the filter.

      Returns AsyncGenerator<FileEntry<`${RootPath}/${string}`>, void, unknown>

      • FileEntry objects representing the files that pass the filter.
    • Find the data (as a Buffer) of a file by its name in the root directory (recursive). This method does not use the filter, so it will return the file if it is found, even if it does not match the filter.

      Type Parameters

      • Name extends string

      Parameters

      • name: Name extends `${string}/${string}` ? never : Name

        The name of the file to find.

      Returns Promise<Buffer<ArrayBufferLike>>

      • A promise fulfilled with the file data as a Buffer if the is found, or undefined if it does not.
    • Find a FileEntry object by its name in the root directory (recursive). This method does not use the filter, so it will return the file if it founds, even if it does not match the filter.

      Type Parameters

      • Name extends string

      Parameters

      • name: Name extends `${string}/${string}` ? never : Name

        The name of the file to find.

      Returns Promise<FileEntry<`${RootPath}/${string}`>>

      • A promise fulfilled with a FileEntry object if the file is found, or undefined if it is not found.
    • Get the data (as a Buffer) of a file for a specific path relative to the root directory. This method does not use the filter, so it will return the data if the file exists, even if it does not match the filter.

      Type Parameters

      • SubPath extends string

      Parameters

      • relativePath: SubPath extends `/${string}` ? never : SubPath

        The relative path of the file (relative to the root directory).

      Returns Promise<Buffer<ArrayBufferLike>>

      • A promise fulfilled with the file data as a Buffer if the file exists, or undefined if it does not.
    • Get a FileEntry object for a specific file path relative to the root directory. This method does not use the filter, so it will return the file if it exists, even if it does not match the filter.

      Type Parameters

      • SubPath extends string

      Parameters

      • relativePath: SubPath extends `/${string}` ? never : SubPath

        The relative path of the file (relative to the root directory).

      Returns Promise<FileEntry<`${RootPath}/${SubPath}`>>

      • A promise fulfilled with a FileEntry object if the file exists, or undefined if it does not.