GithubHelp home page GithubHelp logo

kimjoar / recurse Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 157 KB

Takes a root dir and recursively streams paths.

Home Page: https://npmjs.org/package/recurse

License: Other

JavaScript 94.09% Shell 5.91%

recurse's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.