
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@avdl/folder-walker
Advanced tools
A powerful, fluent, and configurable directory traversal utility for Node.js with TypeScript support
A powerful, fluent, and configurable directory traversal utility for Node.js with TypeScript support.
npm install @avdl/folder-walker
# or
yarn add @avdl/folder-walker
import { FolderWalker } from '@avdl/folder-walker';
// Basic usage - iterate over all files
const walker = new FolderWalker();
for await (const file of walker.files('.')) {
console.log(file.path);
}
// Advanced configuration with async operations
const configuredWalker = new FolderWalker()
.withDepth(3)
.withExtensions(['.ts', '.js'])
.withFileContents('utf-8')
.exclude(['node_modules', '.git'])
.onFile(async ({ path, content }) => {
// Async operations like saving to database, uploading, etc.
await processFile(path, content);
console.log(`Processed ${path}`);
});
await configuredWalker.execute('./src');
withDepth(n) - Set maximum traversal depthwithFilesOnly() - Only traverse fileswithFoldersOnly() - Only traverse folderswithFilesAndFolders() - Traverse both (default)withFileContents(encoding) - Read file contentswithExtensions(extensions) - Filter by file extensionswithPattern(regex) - Filter by filename patternexclude(patterns) - Exclude pathswithHidden() - Include hidden fileswithSymlinks() - Follow symbolic linkswithMaxFileSize(bytes) - Skip large fileswithFilter(asyncFilter) - Add custom async filter functiononFile(handler) - Process each file (supports async functions)onFolder(handler) - Process each folder (supports async functions)onError(handler) - Handle errorswithFileCollector() - Collect file handler results into arraywithFileCollector(collectorFn) - Transform collected results with custom functionwithFolderCollector() - Collect folder handler results into arraywithFolderCollector(collectorFn) - Transform collected results with custom functionexecute(path) - Run with callbacks, returns void (streaming) or collected resultswalker.files(path) - Async iterator for fileswalker.folders(path) - Async iterator for folderswalker.entries(path) - Async iterator for all entriesTry the included examples to see folder-walker in action:
# List all available examples
npm run examples:list
# Run individual examples
npm run example:basic # Basic usage patterns
npm run example:async # Async operations
npm run example:filters # Custom filtering
npm run example:collectors # Type-safe collection
# Run all examples
npm run examples
const walker = new FolderWalker()
.withExtensions(['.ts', '.tsx'])
.exclude(['node_modules', 'dist']);
for await (const file of walker.files('.')) {
console.log(file.path);
}
await new FolderWalker()
.withExtensions(['.md'])
.withFileContents('utf-8')
.onFile(async ({ path, content }) => {
const wordCount = content.split(/\s+/).length;
await saveToDatabase(path, wordCount); // Async operation
console.log(`${path}: ${wordCount} words`);
})
.execute('./docs');
// Streaming mode (no collection) - returns void
await new FolderWalker()
.onFile(({ path }) => {
console.log(`Processing: ${path}`); // void return
})
.execute('./src');
// Collect results - returns ProcessResult[]
const results = await new FolderWalker()
.onFile(({ path, stats }) => ({ path, size: stats.size })) // ProcessResult return
.withFileCollector() // Enable collection
.execute('./src');
// Custom collector transformation - returns ProjectSummary
const summary = await new FolderWalker()
.onFile(({ path, stats }) => ({ path, size: stats.size }))
.withFileCollector((files) => ({
totalFiles: files.length,
totalSize: files.reduce((sum, f) => sum + f.size, 0)
})) // Transform to summary
.execute('./src');
await new FolderWalker()
.withFileContents('utf-8')
.withFilter(async (entry) => {
// Custom filter: files containing specific content
if (entry.isFile && entry.content) {
const hasKeyword = (entry.content as string).includes('TODO');
await logAnalysis(entry.path, hasKeyword); // Async operation
return hasKeyword;
}
return false;
})
.withFilter((entry) => {
// Multiple filters: also check file size
return entry.stats.size < 10000;
})
.onFile(({ path }) => console.log(`TODO found in: ${path}`))
.execute('./src');
const tasks: Promise<void>[] = [];
await new FolderWalker()
.onFile(async ({ path, stats }) => {
if (stats.size > 1024 * 1024) { // 1MB
// Process large files concurrently
const task = processLargeFile(path);
tasks.push(task);
}
})
.execute('.');
// Wait for all concurrent operations
await Promise.all(tasks);
Filters are applied in the following order for optimal performance:
Built-in filters (fastest, applied first):
withHidden())withExtensions())withPattern())withMaxFileSize())Custom filters (withFilter()):
Performance Tips:
MIT
FAQs
A powerful, fluent, and configurable directory traversal utility for Node.js with TypeScript support
The npm package @avdl/folder-walker receives a total of 1 weekly downloads. As such, @avdl/folder-walker popularity was classified as not popular.
We found that @avdl/folder-walker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.