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

Method readFile

lib/internal/vfs/provider.js:246–255  ·  view source on GitHub ↗

* Reads a file. * @param {string} path The file path * @param {object|string} [options] Options or encoding * @returns {Promise }

(path, options)

Source from the content-addressed store, hash-verified

244 * @returns {Promise<Buffer|string>}
245 */
246 async readFile(path, options) {
247 const flag = (typeof options === 'object' && options !== null) ?
248 (options.flag ?? 'r') : 'r';
249 const handle = await this.open(path, flag);
250 try {
251 return await handle.readFile(options);
252 } finally {
253 await handle.close();
254 }
255 }
256
257 /**
258 * Reads a file synchronously.

Callers 2

copyFileMethod · 0.95
readFileFunction · 0.45

Calls 2

openMethod · 0.95
closeMethod · 0.65

Tested by

no test coverage detected