MCPcopy Index your code
hub / github.com/nodejs/node / readFile

Method readFile

lib/internal/vfs/file_handle.js:590–601  ·  view source on GitHub ↗

* Reads the entire file. * @param {object|string} [options] Options or encoding * @returns {Promise }

(options)

Source from the content-addressed store, hash-verified

588 * @returns {Promise<Buffer|string>}
589 */
590 async readFile(options) {
591 this.#checkClosed('read');
592 this.#checkReadable();
593
594 // Get content asynchronously (supports async content providers)
595 const content = await this.getContentAsync();
596 const encoding = typeof options === 'string' ? options : options?.encoding;
597 if (encoding) {
598 return content.toString(encoding);
599 }
600 return Buffer.from(content);
601 }
602
603 /**
604 * Writes data to the file synchronously.

Callers

nothing calls this directly

Calls 5

#checkClosedMethod · 0.95
#checkReadableMethod · 0.95
getContentAsyncMethod · 0.95
toStringMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected