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

Function readdirSync

lib/fs.js:1868–1891  ·  view source on GitHub ↗

* Synchronously reads the contents of a directory. * @param {string | Buffer | URL} path * @param {string | { * encoding?: string; * withFileTypes?: boolean; * recursive?: boolean; * }} [options] * @returns {string | Buffer[] | Dirent[]}

(path, options)

Source from the content-addressed store, hash-verified

1866 * @returns {string | Buffer[] | Dirent[]}
1867 */
1868function readdirSync(path, options) {
1869 const h = vfsState.handlers;
1870 if (h !== null) {
1871 const result = h.readdirSync(path, options);
1872 if (result !== undefined) return result;
1873 }
1874 options = getOptions(options);
1875 path = getValidatedPath(path);
1876 if (options.recursive != null) {
1877 validateBoolean(options.recursive, 'options.recursive');
1878 }
1879
1880 if (options.recursive) {
1881 return readdirSyncRecursive(path, options);
1882 }
1883
1884 const result = binding.readdir(
1885 path,
1886 options.encoding,
1887 !!options.withFileTypes,
1888 );
1889
1890 return result !== undefined && options.withFileTypes ? getDirents(path, result) : result;
1891}
1892
1893/**
1894 * Invokes the callback with the `fs.Stats`

Calls 5

readdirSyncRecursiveFunction · 0.85
getDirentsFunction · 0.85
getOptionsFunction · 0.50
readdirSyncMethod · 0.45
readdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…