• Asynchronously reads the entire contents of a file.

    Parameters

    • path: PathOrFileDescriptor

      A path to a file. If a URL is provided, it must use the file: protocol. If a file descriptor is provided, the underlying file will not be closed automatically.

    • Optional options: null | {
          encoding?: null;
          flag?: string;
      }

      An object that may contain an optional flag. If a flag is not provided, it defaults to 'r'.

    Returns Promise<Buffer>

  • Asynchronously reads the entire contents of a file.

    Parameters

    • path: PathOrFileDescriptor

      A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. If a file descriptor is provided, the underlying file will not be closed automatically.

    • options: BufferEncoding | {
          encoding: BufferEncoding;
          flag?: string;
      }

      Either the encoding for the result, or an object that contains the encoding and an optional flag. If a flag is not provided, it defaults to 'r'.

    Returns Promise<string>

  • Asynchronously reads the entire contents of a file.

    Parameters

    • path: PathOrFileDescriptor

      A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. If a file descriptor is provided, the underlying file will not be closed automatically.

    • Optional options: null | BufferEncoding | ObjectEncodingOptions & {
          flag?: string;
      }

      Either the encoding for the result, or an object that contains the encoding and an optional flag. If a flag is not provided, it defaults to 'r'.

    Returns Promise<string | Buffer>