@playform/maintain - v0.1.8
    Preparing search index...
    readFile: {
        (
            path: PathLike | FileHandle,
            options?: null | { encoding?: null; flag?: OpenMode } & Abortable,
        ): Promise<NonSharedBuffer>;
        (
            path: PathLike | FileHandle,
            options:
                | { encoding: BufferEncoding; flag?: OpenMode | undefined } & Abortable
                | BufferEncoding,
        ): Promise<string>;
        (
            path: PathLike | FileHandle,
            options?:
                | null
                | BufferEncoding
                | ObjectEncodingOptions & Abortable & { flag?: OpenMode | undefined },
        ): Promise<string | NonSharedBuffer>;
    }

    Type declaration

      • (
            path: PathLike | FileHandle,
            options?: null | { encoding?: null; flag?: OpenMode } & Abortable,
        ): Promise<NonSharedBuffer>
      • Asynchronously reads the entire contents of a file.

        If no encoding is specified (using options.encoding), the data is returned as a Buffer object. Otherwise, the data will be a string.

        If options is a string, then it specifies the encoding.

        When the path is a directory, the behavior of fsPromises.readFile() is platform-specific. On macOS, Linux, and Windows, the promise will be rejected with an error. On FreeBSD, a representation of the directory's contents will be returned.

        An example of reading a package.json file located in the same directory of the running code:

        import { readFile } from 'node:fs/promises';
        try {
        const filePath = new URL('./package.json', import.meta.url);
        const contents = await readFile(filePath, { encoding: 'utf8' });
        console.log(contents);
        } catch (err) {
        console.error(err.message);
        }

        It is possible to abort an ongoing readFile using an AbortSignal. If a request is aborted the promise returned is rejected with an AbortError:

        import { readFile } from 'node:fs/promises';

        try {
        const controller = new AbortController();
        const { signal } = controller;
        const promise = readFile(fileName, { signal });

        // Abort the request before the promise settles.
        controller.abort();

        await promise;
        } catch (err) {
        // When a request is aborted - err is an AbortError
        console.error(err);
        }

        Aborting an ongoing request does not abort individual operating system requests but rather the internal buffering fs.readFile performs.

        Any specified FileHandle has to support reading.

        Parameters

        • path: PathLike | FileHandle

          filename or FileHandle

        • Optionaloptions: null | { encoding?: null; flag?: OpenMode } & Abortable

        Returns Promise<NonSharedBuffer>

        Fulfills with the contents of the file.

        v10.0.0

      • (
            path: PathLike | FileHandle,
            options:
                | { encoding: BufferEncoding; flag?: OpenMode | undefined } & Abortable
                | BufferEncoding,
        ): Promise<string>
      • Asynchronously reads the entire contents of a file.

        Parameters

        • path: PathLike | FileHandle

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

        • options:
              | { encoding: BufferEncoding; flag?: OpenMode | undefined } & Abortable
              | BufferEncoding

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

        Returns Promise<string>

      • (
            path: PathLike | FileHandle,
            options?:
                | null
                | BufferEncoding
                | ObjectEncodingOptions & Abortable & { flag?: OpenMode | undefined },
        ): Promise<string | NonSharedBuffer>
      • Asynchronously reads the entire contents of a file.

        Parameters

        • path: PathLike | FileHandle

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

        • Optionaloptions:
              | null
              | BufferEncoding
              | ObjectEncodingOptions & Abortable & { flag?: OpenMode | undefined }

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

        Returns Promise<string | NonSharedBuffer>