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

Method writeFile

lib/internal/vfs/provider.js:281–292  ·  view source on GitHub ↗

* Writes a file. * @param {string} path The file path * @param {Buffer|string} data The data to write * @param {object} [options] Options * @returns {Promise }

(path, data, options)

Source from the content-addressed store, hash-verified

279 * @returns {Promise<void>}
280 */
281 async writeFile(path, data, options) {
282 if (this.readonly) {
283 throw createEROFS('open', path);
284 }
285 const flag = options?.flag ?? 'w';
286 const handle = await this.open(path, flag, options?.mode);
287 try {
288 await handle.writeFile(data, options);
289 } finally {
290 await handle.close();
291 }
292 }
293
294 /**
295 * Writes a file synchronously.

Callers 3

copyFileMethod · 0.95
writeFileFunction · 0.45
appendFileMethod · 0.45

Calls 3

openMethod · 0.95
createEROFSFunction · 0.85
closeMethod · 0.65

Tested by

no test coverage detected