INNER CODE UNIT · JavaScript

walk

pegaltier/awesome-utils-dev · node_scripts/wip-dedupe.js:51

function walk(dir, out = []) {
    for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
        if (entry.isDirectory()) {
            if (!SKIP_DIRS.has(entry.name)) walk(path.join(dir, entry.name), out);
        } else if (!SKIP_FILES.has(entry.name) && SCAN_EXT.has(path.extname(entry.name))) {
            out.push(path.join(dir, entry.name));
        }
    }
    return out;
}

// --- index the repo ---------------------------------------------------------

const files = walk(ROOT);
const urlIndex = new Map(); // normalized url -> relative file path
const textIndex = []; // { file, content } for plain-text lookups

for (const file of files) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…