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

Function exists

lib/fs.js:282–303  ·  view source on GitHub ↗

* Tests whether or not the given path exists. * @param {string | Buffer | URL} path * @param {(exists?: boolean) => any} callback * @returns {void}

(path, callback)

Source from the content-addressed store, hash-verified

280 * @returns {void}
281 */
282function exists(path, callback) {
283 validateFunction(callback, 'cb');
284
285 const h = vfsState.handlers;
286 if (h !== null) {
287 const result = h.existsSync(path);
288 if (result !== undefined) {
289 process.nextTick(callback, result);
290 return;
291 }
292 }
293
294 function suppressedCallback(err) {
295 callback(!err);
296 }
297
298 try {
299 fs.access(path, F_OK, suppressedCallback);
300 } catch {
301 return callback(false);
302 }
303}
304
305ObjectDefineProperty(exists, kCustomPromisifiedSymbol, {
306 __proto__: null,

Callers 10

GetTestStatusMethod · 0.85
GetVmMethod · 0.85
IsSuiteFunction · 0.85
MainFunction · 0.85
RunCommandMethod · 0.85
ListTestsMethod · 0.85
ListTestsMethod · 0.85
FindFilesInMethod · 0.85
_GetStatusFilesMethod · 0.85

Calls 3

callbackFunction · 0.50
existsSyncMethod · 0.45
accessMethod · 0.45

Tested by 7

GetTestStatusMethod · 0.68
GetVmMethod · 0.68
IsSuiteFunction · 0.68
MainFunction · 0.68
RunCommandMethod · 0.68
ListTestsMethod · 0.68
ListTestsMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…