Home

Awesome

level-glob

Create a read stream filtered and ordered by glob patterns. The keys in the database should be absolute, unix-like paths.

npm status Travis build status AppVeyor build status Dependency status

Jump to: usage / install / license

example

var level  = require('level-test')({ mem: true })
  , glob   = require('level-glob')
  , concat = require('concat-stream')

// create a database
var db = level()

// insert some data
var ops = [
  {type: 'put', key: '/readme.md',      value: 'readme' },
  {type: 'put', key: '/assets/app.js',  value: 'js'     },
  {type: 'put', key: '/assets/app.css', value: 'css'    }
]

db.batch(ops, function(){

  var opts = { values: true, keys: false }

  // aggregates multiple streams
  glob(db, ['assets/*', '/*'], opts)
    .pipe(concat(function(value){
      console.log(value === 'cssjsreadme')
    }))

  // but those streams are ordered
  glob(db, ['/*', 'assets/*'], opts)
    .pipe(concat(function(value){
      console.log(value === 'readmecssjs')
    }))

  // negation only applies to patterns before it
  glob(db, ['assets/*', '!**.md', '/*'], opts)
    .pipe(concat(function(value){
      console.log(value === 'cssjsreadme')
    }))

  // so this negative glob does have an effect
  glob(db, ['assets/*', '/*', '!**.md'], opts)
    .pipe(concat(function(value){
      console.log(value === 'cssjs')
    }))

})

usage

glob(db, patterns(s)[, options])

Create a readstream filtered by one or more glob patterns.

glob.install(db)

Add a createGlobStream method to db.

glob.install(db);
db.createGlobStream('/**/*.png', options);

install

With npm do:

npm install level-glob

license

MIT © Vincent Weevers