Function readFileSafe

  • Reads a file and returns the file's contents.

    Identical to fs.promises.readFile, except that:

    • it uses utf8 encoding by default
    • if operation fails, returns undefined instead of throwing

    Parameters

    • filepath: string

      The path to the file.

    • encoding: BufferEncoding = 'utf8'

      The encoding to use when reading the file.

    Returns Promise<string | undefined>

    A promise that resolves with the file's contents or undefined if the file does not exist.

Generated using TypeDoc