pull-glob

extended globs as pull-streams

pull-glob

streaming extended glob.

use with pull-stream

var pull = require('pull-stream')
var glob = require('pull-glob')
 
glob('.')      .pipe(log()) // current dir 
glob('*.js')   .pipe(log()) // current dir 
glob('**')     .pipe(log()) // everything under current dir 
glob('**/*.js').pipe(log()) // .js recursively 
glob('...')    .pipe(log()) // parent directories 
glob('.../.*') .pipe(log()) // hidden files 
glob('.../node_modules/*')
                .pipe(log()) // available modules! 
glob('.../{package,component}.json')
                .pipe(log()) // search for local package files. 
 
function log () {
  return pull.drain(console.log)
}

because this module uses pull-streams, it's lazy, so you can do queries like the following:

//find the first package.json in a parent directory. 
glob('.../package.json').pipe(pull.take(1)).pipe(log())

And you will retrive only the first item, and will not do any extra IO. This is hugely useful when doing a large traversal...

glob('**/node_modules/*/package.json')
  .pipe(pull.collect(function (earr) {
    console.log(arr)
  })
 

MIT