MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / search

Function search

code/solutions/20_1_search_tool.mjs:9–18  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

7}
8
9function search(file) {
10 let stats = statSync(file);
11 if (stats.isDirectory()) {
12 for (let f of readdirSync(file)) {
13 search(file + "/" + f);
14 }
15 } else if (searchTerm.test(readFileSync(file, "utf8"))) {
16 console.log(file);
17 }
18}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected