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

Method readFileSync

lib/internal/vfs/file_handle.js:572–583  ·  view source on GitHub ↗

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

(options)

Source from the content-addressed store, hash-verified

570 * @returns {Buffer|string}
571 */
572 readFileSync(options) {
573 this.#checkClosed('read');
574 this.#checkReadable();
575
576 // Get content (resolves dynamic content providers)
577 const content = this.content;
578 const encoding = typeof options === 'string' ? options : options?.encoding;
579 if (encoding) {
580 return content.toString(encoding);
581 }
582 return Buffer.from(content);
583 }
584
585 /**
586 * Reads the entire file.

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected