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

Method readSync

lib/internal/fs/dir.js:209–242  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

207 }
208
209 readSync() {
210 if (this.#closed === true) {
211 throw new ERR_DIR_CLOSED();
212 }
213
214 if (this.#operationQueue !== null) {
215 throw new ERR_DIR_CONCURRENT_OPERATION();
216 }
217
218 if (this.#processHandlerQueue()) {
219 const dirent = ArrayPrototypeShift(this.#bufferedEntries);
220 if (this.#options.recursive && dirent.isDirectory()) {
221 this.#readSyncRecursive(dirent);
222 }
223 return dirent;
224 }
225
226 const result = this.#handle.read(
227 this.#options.encoding,
228 this.#options.bufferSize,
229 );
230
231 if (result === null) {
232 return result;
233 }
234
235 this.#processReadResult(this.#path, result);
236
237 const dirent = ArrayPrototypeShift(this.#bufferedEntries);
238 if (this.#options.recursive && dirent.isDirectory()) {
239 this.#readSyncRecursive(dirent);
240 }
241 return dirent;
242 }
243
244 close(callback) {
245 if (callback === undefined) {

Callers 15

tryReadSyncFunction · 0.45
readSyncFunction · 0.45
readlineFunction · 0.45
cleanupMethod · 0.45
copyDirFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 5

#processHandlerQueueMethod · 0.95
#readSyncRecursiveMethod · 0.95
#processReadResultMethod · 0.95
isDirectoryMethod · 0.45
readMethod · 0.45

Tested by 1

testFunction · 0.36