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

Function readdir

deps/npm/test/lib/docs.js:92–107  ·  view source on GitHub ↗
(dir, ext)

Source from the content-addressed store, hash-verified

90
91t.test('usage', async t => {
92 const readdir = async (dir, ext) => {
93 const files = await fs.readdir(dir, { withFileTypes: true })
94 return files
95 .filter(f => {
96 // Include .js files
97 if (f.isFile() && extname(f.name) === ext) {
98 return true
99 }
100 // Include directories (which should have an index.js)
101 if (f.isDirectory()) {
102 return true
103 }
104 return false
105 })
106 .map(f => f.isDirectory() ? f.name : basename(f.name, ext))
107 }
108
109 const fsCommands = await readdir(resolve(__dirname, '../../lib/commands'), '.js')
110 const docsCommands = await readdir(join(docs.paths.content, 'commands'), docs.DOC_EXT)

Callers 5

docs.jsFile · 0.70
completionMethod · 0.50
isDirMatchMethod · 0.50
completionMethod · 0.50
checkFilesPermissionMethod · 0.50

Calls 7

basenameFunction · 0.85
mapMethod · 0.65
filterMethod · 0.65
extnameFunction · 0.50
readdirMethod · 0.45
isFileMethod · 0.45
isDirectoryMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…