Function readFile

  • Asynchronously reads the entire contents of a file.

    Parameters

    • path: PathLike | FileHandle
    • Optionaloptions: null | {
          encoding?: null;
          flag?: OpenMode;
      }

    Returns Promise<Buffer>

    the file data

    encoding The string encoding for the file contents. Defaults to null.

    flag Defaults to 'r'.

  • Parameters

    • path: PathLike | FileHandle
    • options: BufferEncoding | {
          encoding: BufferEncoding;
          flag?: OpenMode | undefined;
      }

    Returns Promise<string>

  • Parameters

    • path: PathLike | FileHandle
    • Optionaloptions: null | BufferEncoding | ObjectEncodingOptions & {
          flag?: OpenMode | undefined;
      }

    Returns Promise<string | Buffer>