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

Function readFileSync

lib/internal/vfs/setup.js:190–205  ·  view source on GitHub ↗
(path, options)

Source from the content-addressed store, hash-verified

188 return r !== null ? r.exists : undefined;
189 },
190 readFileSync(path, options) {
191 if (typeof path === 'number') {
192 const vfd = getVirtualFd(path);
193 if (vfd) {
194 const enc = typeof options === 'string' ? options : options?.encoding;
195 if (enc && enc !== 'buffer') assertEncoding(enc);
196 return vfd.entry.readFileSync(options);
197 }
198 return undefined;
199 }
200 const pathStr = toPathStr(path);
201 if (pathStr === null) return undefined;
202 const enc = typeof options === 'string' ? options : options?.encoding;
203 if (enc && enc !== 'buffer') assertEncoding(enc);
204 return findVFSWith(pathStr, 'open', (vfs, n) => vfs.readFileSync(n, options));
205 },
206 readdirSync(path, options) {
207 const result = vfsRead(path, 'scandir', (vfs, n) => vfs.readdirSync(n, options));
208 if (result !== undefined && options?.encoding === 'buffer' && !options?.withFileTypes) {

Callers 8

getLinesMethod · 0.50
parsePreviousRunsFunction · 0.50
readFileMethod · 0.50
createFileAssertMethod · 0.50
sourceMapFromFileFunction · 0.50
getOriginalSourceFunction · 0.50

Calls 5

getVirtualFdFunction · 0.85
assertEncodingFunction · 0.85
toPathStrFunction · 0.85
findVFSWithFunction · 0.85
readFileSyncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…