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

Function appendFile

lib/fs.js:2960–2983  ·  view source on GitHub ↗

* Asynchronously appends data to a file. * @param {string | Buffer | URL | number} path * @param {string | Buffer} data * @param {{ * encoding?: string | null; * mode?: number; * flag?: string; * flush?: boolean; * } | string} [options] * @param {(err?: Error) => any} callback *

(path, data, options, callback)

Source from the content-addressed store, hash-verified

2958 * @returns {void}
2959 */
2960function appendFile(path, data, options, callback) {
2961 callback ||= options;
2962 validateFunction(callback, 'cb');
2963
2964 options = getOptions(typeof options === 'function' ? null : options, {
2965 encoding: 'utf8', mode: 0o666, flag: 'a',
2966 });
2967 parseFileMode(options.mode, 'mode', 0o666);
2968
2969 const h = vfsState.handlers;
2970 if (h !== null) {
2971 if (checkAborted(options.signal, callback)) return;
2972 if (vfsVoid(h.appendFile(path, data, options), callback)) return;
2973 }
2974
2975 // Don't make changes directly on options object
2976 options = copyObject(options);
2977
2978 // Force append behavior when using a supplied file descriptor
2979 if (!options.flag || isFd(path))
2980 options.flag = 'a';
2981
2982 fs.writeFile(path, data, options, callback);
2983}
2984
2985/**
2986 * Synchronously appends data to a file.

Callers

nothing calls this directly

Calls 7

parseFileModeFunction · 0.85
vfsVoidFunction · 0.85
copyObjectFunction · 0.85
checkAbortedFunction · 0.70
getOptionsFunction · 0.50
appendFileMethod · 0.45
writeFileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…