Stone.js API
    Preparing search index...

    Hierarchy (View Summary)

    Index
    • Create a File.

      Parameters

      • path: string

        The file path.

      • checkPath: boolean = true

        Whether to check if the file path is valid.

      Returns File

    • Edit file content.

      Parameters

      • callback: (content: string) => string

        The callback function to modify the file content.

      Returns this

      The current File instance.

    • Check if the file exists.

      Returns boolean

      True if the file exists, otherwise false.

    • Get the absolute file path.

      Parameters

      • root: string = ''

        The root directory to resolve from.

      Returns string

      The absolute file path.

    • Get the last access time of the file.

      Returns StatTimeMs

      The last access time in milliseconds.

    • Get the basename of the file.

      Parameters

      • exclude: string = ''

        The file extension to exclude from the basename.

      Returns string

      The basename of the file.

    • Get the raw file content as a Buffer (binary-safe).

      Returns Buffer

      The content of the file as a Buffer.

      FilesystemError if the file cannot be read.

    • Get file content.

      Parameters

      • encoding: BufferEncoding = 'utf-8'

      Returns string

      The content of the file as a string.

    • Get the created time of the file.

      Returns StatTimeMs

      The created time in milliseconds.

    • Get the directory name of the file.

      Returns string

      The directory name.

    • Get the encoded absolute file path.

      Parameters

      • root: string = ''

        The root directory to resolve from.

      Returns string

      The encoded absolute file path.

    • Get the encoded file path.

      Returns string

      The encoded file path.

    • Get the file extension.

      Returns string

      The file extension.

    • Get the filename of the file.

      Returns string

      The filename of the file.

    • Get the hashed content of the file.

      Parameters

      • algo: string = 'sha256'

        The hashing algorithm to use.

      Returns string

      The hashed content of the file as a hex string.

    • Get the MIME type of the file.

      Returns string

      The MIME type of the file.

    • Get the MIME type of the file.

      Parameters

      • fallback: string

        A fallback MIME type if detection fails.

      Returns string

      The MIME type of the file.

    • Get the last modified time of the file.

      Returns StatTimeMs

      The last modified time in milliseconds.

    • Get the name of the file without extension.

      Returns string

      The name of the file.

    • Get the file path.

      Returns string

      The file path.

    • Get file size.

      Parameters

      • formatted: boolean = false

        Whether to return the file size as a formatted string.

      Returns string | StatTimeMs

      The file size as a string or number.

    • Check if the file path is absolute.

      Returns boolean

      True if the file path is absolute, otherwise false.

    • Check if the file is compressed.

      Parameters

      • extensions: string[] = ...

      Returns boolean

      True if the file is compressed, otherwise false.

    • Check if the file is a directory.

      Returns boolean

      True if the file is a directory, otherwise false.

    • Check if the file is executable.

      Returns boolean

      True if the file is executable, otherwise false.

    • Check if the file is a regular file.

      Returns boolean

      True if the file is a regular file, otherwise false.

    • Check if the file is a symbolic link.

      Returns boolean

      True if the file is a symbolic link, otherwise false.

    • Check if the file path starts with a provided prefix.

      Parameters

      • prefix: string

      Returns boolean

      True if the file path starts with the provided prefix, otherwise false.

    • Check if the file is readable.

      Returns boolean

      True if the file is readable, otherwise false.

    • Check if the file is writable.

      Returns boolean

      True if the file is writable, otherwise false.

    • Move file to a new directory.

      Parameters

      • directory: string

        The target directory.

      • Optionalname: string

        The new name for the file.

      Returns File

      The new File instance representing the moved file.

      FileError if the file could not be moved.

    • Remove file.

      Parameters

      • force: boolean = false

        Whether to forcefully remove the file.

      Returns this

      The current File instance.

    • Write content to file (creating it if it does not exist).

      Parameters

      • content: string | Buffer<ArrayBufferLike>

        The content to write to the file.

      Returns this

      The current File instance.

      FilesystemError if the content cannot be written.

    • Create a File.

      Parameters

      • path: string

        The file path.

      • checkPath: boolean = true

        Whether to check if the file path is valid.

      Returns File

      A new File instance.