Skip to content

kimjoar/recurse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

recurse

Takes a root dir and recursively streams paths.

build status

Example

var recurse = require('recurse');

// recursively write all filetypes except directories:
recurse('.').pipe(process.stdout);

// recursively write js files:
function js(relname, stat) {
  return !stat.isDirectory() && relname.match(/\.js$/)
}
recurse('.', {writefilter: js}).pipe(process.stdout);

// recursively write dirs:
function dir(relname, stat) {
  return stat.isDirectory();
}
recurse('.', {writefilter: dir}).pipe(process.stdout);

// non-recursively write all files:
function none(relname, stat) {
  return false;
}
recurse('.', {recursefilter: none}).pipe(process.stdout);

// recurse into test/ and write js files :
function test(relname, stat) {
  return stat.isDirectory() && ~relname.indexOf('test');
}
recurse('.', {recursefilter: test, writefilter: js}).pipe(process.stdout);

Mehods

var recurse = require('recurse');

var s = recurse(root, opts={})

Return a redable stream of all paths beneath a root directory.

Optionally pass in the following opts:

  • opts.writefilter - custom function for determining whether to write a path to the recurse stream using a opts.writefilter(relname, stat) signature.
  • opts.recursefilter - custom function for determining whether to recurse a path using a opts.writefilter(relname, stat) signature.
  • opts.resolvesymlinks - if set to true symbolic links will be resolved

Performance

recurse is about an order of magniture slower than GNU find after a couple of runs on my home directory. See the benchmark for detailed results against other node modules.

License

MIT

About

Takes a root dir and recursively streams paths.

Resources

License

Stars

Watchers

Forks

Packages

No packages published