recurse

3.0.2 • Public • Published

recurse

Takes a root dir and recursively streams paths.

build status dependency status dev dependency 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

Compatibility

Node 0.8.x will use the readable-stream module while node 0.10.x and newer will use the core Readable stream class.

Performance

recurse is about an order of magnitude 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

Readme

Keywords

none

Package Sidebar

Install

npm i recurse

Weekly Downloads

112

Version

3.0.2

License

MIT

Last publish

Collaborators

  • uggedal