Skip to content

ericlathrop/node-fs-walk-breadth-first

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-fs-walk-breadth-first

Call a function on each file in a filesystem tree

Example

var walk = require("fs-walk-breadth-first");
walk(".", function(filename, stats) {
	console.log(filename, stats.isDirectory());
}, function(err) {
	if (err) {
		console.error(err);
		return;
	}
	console.log("finished!");
});

Installation

npm install --save fs-walk-breadth-first

walk(directory, iterator, callback)

Traverses all files and directories beneath directory in breadth-first order. The iterator function is called on each file or directory, and the callback function is called after all files and directories have been visited.

Arguments

  • directory - The directory to traverse.
  • iterator(filename, stats, callback) - A function to apply to each file or directory found. stats is an instance of fs.Stats. callback(err) should be called when the iterator is finished
  • callback(err) - A function that is called when all the files and directories have been visited, or when an error occurs.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

About

Call a function on each file in a filesystem tree

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published